One, using JSP
APP Engine Java provides almost complete support for JSP,JSTL. This lesson mainly describes how to use JSP and Jstl in Gae for Java.
Open the Eclipse menu->preferences->java->installed JREs, add the JDK installation directory, and set it to default. The default eclipse points only to the JRE directory.
Open the Gapp_flexblog project and add the JSP file greeting_via_jsp.jsp under the war directory as follows:
<% @page contenttype= "Text/html;charset=utf-8" language= "java"%>
<% @page import= "Sban.flexblog.HelloWorldUsingJPA"%>
<% @page import= "Sban.flexblog.GreetingEntity"%>
<% @page import= "Java.util.List"%>
<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= "></input><br/>"
Greeting Content:<input value= "greeting content1" name= "Greetingcontent" maxlength= "the" "></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>
<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>