In the Java Servlet, how to include original paramters after response ?
Servlet
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String cmd = request.getParameter("cmd");
System.out.println("service , cmd="+cmd);
request.setAttribute("name", "John"+System.currentTimeMillis());
RequestDispatcher rd = request.getRequestDispatcher("process.jsp");
rd.include(request, response);
}
JSP
main ${name}<br>
cmd ${cmd}
- If I want to include all paramters, like "cmd", to a new jsp page, how to do it ?
- based on No.1, if I want to add NEW attributes, like "name" to a new jsp page, how to do it ?
- In the above codes, use include or forward, the results are same. why ?
Thanks