基于flex4技术从零开发flex博客系统: 8 using jsp and jstl
2009-05-05 12:06:05 来源:WEB开发网一,using jsp
App Engine java提供对JSP,JSTL的几乎完全支持。本课主要介绍如何在GAE for java中使用jsp及jstl。
打开eclipse菜单->Preferences->Java->Installed JREs,添加jdk安装目录,并设为默认。默认eclipse仅指向了jre目录。
打开gapp_flexblog项目,在war目录下添加jsp文件greeting_via_jsp.jsp,如下:
<%@page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="sban.flexblog.HelloWorldUsingJPA"%>
<%@page import="sban.flexblog.GreetingEntity"%>
<%@page import="java.util.List"%>
<html>
<body>
<%
if (null != request.getParameter("message"))
{
String action = request.getParameter("message");
response.getWriter().write(action + "<br />");
}
%>
<form action="/gapp_flexblog/hello" method="post">
user:<input name="username" value="sban" maxlength="50" ></input><br />
greeting content:<input value="greeting content1" name="greetingContent" maxlength="250" ></input><br />
<input type="hidden" name="action" value="new" />
<input type="submit" value="Post Greeting" />
</form>
<div>
<form action="/gapp_flexblog/hello" method="post">
<input type="submit" value="Delete All Greetings" />
<input type="hidden" name="action" value="delall" />
</form>
</div>
<div>
<h3>Greetings list:</h3>
<ul style="list-style: decimal;">
<%
HelloWorldUsingJPA operator = new HelloWorldUsingJPA();
List<GreetingEntity> greetings = operator.getAllGreetings();
if (greetings.size() > 0)
{
for(GreetingEntity greeting : greetings)
{
%>
<li>
id:<%= greeting.getId() %>
user:<%= greeting.getUser() %>
greetingContent:<%= greeting.getGreetingContent() %>
date: <%=greeting.getDate().toString() %>
</li>
<%
}
}else{
%>
<li>Empty!</li>
<%
}
%>
</ul>
</div>
</body>
</html>
更多精彩
赞助商链接