PageServlet.java
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:1k
源码类别:
Java编程
开发平台:
Java
- package bible.servlets;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import java.io.*;
- import java.util.*;
- public class PageServlet extends HttpServlet {
- public void service(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- HttpSession session = request.getSession();
- Hashtable sessionInfo = (Hashtable) session.getAttribute("sessionInfo");
- String userName = (String) sessionInfo.get("userName");
- Integer pageNumber = (Integer) sessionInfo.get("pageNumber");
- response.setContentType("text/html");
- PrintWriter out = response.getWriter();
- out.println("<html>");
- out.println("<head><title>ApplicationServlet</title></head>");
- out.println("<body>");
- out.println("<p>Welcome to the ApplicationServlet.</p>");
- out.println("<p>Your name is " + userName + " and you are on page " + pageNumber.intValue() + ".</p>");
- out.println("<p></p>");
- out.println("<p><a href="" + response.encodeURL("ApplicationServlet?action=next") + "">Next Page</a></p>");
- out.println("<p></p>");
- out.println("<p><a href="" + response.encodeURL("ApplicationServlet?action=previous") + "">Previous Page</a></p>");
- out.println("<p></p>");
- out.println("<p><a href="" + response.encodeURL("ApplicationServlet?action=logoff") + "">Log Off</a></p>");
- out.println("</body></html>");
- }
- }