|
| Java关键字导航 |
| 网络 J2ME 手机游戏 JavaCard Struts 游戏 分析器 JAAS EJB JavaMail 设计模式 J2EE |
| import javax.servlet.*; import java.io.*; public class Header extends GenericServlet { public void service(ServletRequest req,ServletResponse resp) throws ServletException, IOException { res.setContentType("text/html;charset=gb2312"); PrintWriter out =res.getWriter(); // Get the title of the page. Set to empty string if // no title parameter was given String titles[] = req.getParameterValues("title"); String title = ""; if (titles != null) { if (titles.length > 0) { title = titles[0]; } } // Format the standard header out.println("<head><title> 欢迎你到来 </title></head>"); out.println("<H1 align='center'>*** 欢迎你到来 *** </H1><hr>"); // Wrap up out.flush(); out.close(); } /** * <p>Returns information about this servlet */ public String getServletInfo() { return "Header "; } public void init(ServletConfig cfg) throws ServletException { super.init(cfg); } public void destroy() { super.destroy(); } } |
| import javax.servlet.*; import java.io.*; public class Footer extends GenericServlet { public void service(ServletRequest req,ServletResponse resp) throws ServletException, IOException { res.setContentType("text/html;charset=gb2312"); PrintWriter out =res.getWriter(); // Format the standard header out.println("<hr>"); out.println("<p align='center'><i> 版权所有,信息公司</i></p>"); // Wrap up out.flush(); out.close(); } /** * <p>Returns information about this servlet */ public String getServletInfo() { return "Footer "; } public void init(ServletConfig cfg) throws ServletException { super.init(cfg); } public void destroy() { super.destroy(); } } |
| <html> <servlet code=Header> <param name="title" value="GOOD"> </servlet> <body> <dir> This a study programmer!;<br> Are you Interested in ?;<br> Let's go Research.<br> </dir> <servlet code=Footer> </servlet> </body> </html> |