HttpServletResponse object

in the below code,,why we r passing response object as the parameter to the sendPage2 method..... generally what request object and response object holds here.

public void doPost(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

firstName = request.getParameter("firstName");

lastName = request.getParameter("lastName");

if (firstName==null || lastName==null)

response.sendRedirect(page1Url);

sendPage2(response);

}

void sendPage2(HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("text/html");

PrintWriter out = response.getWriter();

out.println("<HTML>");

out.println("<HEAD>");

out.println("<TITLE>Page 2</TITLE>");

out.println("</HEAD>");

out.println("<BODY>");

out.println("<CENTER>");

[937 byte] By [bobza] at [2007-9-23]
# 1

>why we r passing response object as the parameter to the sendPage2 method

Look at the sendPage2(HttpServletResponse response) method

>response.setContentType("text/html");

>PrintWriter out = response.getWriter();

You set some attributes in line 1 in the response object

You get some attributes in line 2 from the response object.

cheers,

ram.

Madathil_Prasada at 2007-7-11 > top of java,Enterprise & Remote Computing,Web Tier APIs...