Hello JSP
Java Server Pages are actually translated into code,
compiled into servlets, and run--just like servlets.
JSP syntax elements include:
| Directives |
<%@ directive %> |
| Declaration |
<%! Java declaration %> |
| Scriptlet |
<% some Java code %> |
| Expression |
<%= an expression %> |
| Action |
<%jsp:actionName /> |
| Comment |
<%-- comment; code --%> |
|
<html>
<head>
<title>Hello Yourself</title>
</head>
<body>
<h1>Hello JSP says Hello to <%= request.getRemoteAddr()%>!</h1>
</body>
</html>
|
public class hello$jsp extends HttpJspBase {
public void _jspService( HttpServletRequest request,
HttpServletResponse response)
throws java.io.IOException, ServletException {
PageContext pageContext = factory.getPageContext(this);
ServletContext application = pageContext.getServletContext();
ServletConfig config = pageContext.getServletConfig();
HttpSession session = pageContext.getSession();
JspWriter out = pageContext.getOut();
try {
response.setContentType("text/html;charset=ISO-8859-1");
out.write("<html>\r\n<head>\r\n<title>Hello Yourself"
+ "</title>\r\n</head>\r\n<body>\r\n<h1>Hello ");
out.print(request.getRemoteAddr());
out.write("!</h1>\r\n</body>\r\n</html>\r\n\r\n");
} catch (Throwable t) {
// handle exception
} finally {
// release context
}
}
}
|
|