Scripts- Server Side-JSP [Computer Associates Placement]: Sample Questions 10 - 10 of 18

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 10

Appeared in Year: 2004

Question

MCQ▾

What is the key difference between using a < jsp: Forward > and HttpServletResponse. SendRedirect () ?

Choices

Choice (4)

a.

The two methods perform identically.

b.

Forward executes on the client while sendRedirect () executes on the server.

c.

Forward executes on the server while sendRedirect () executes on the client.

d.

Question does not provide sufficient data or is vague

Answer

c.

Explanation

Table Shows the Forward () and Sendredirect ()
Forward ()SendRedirect ()
The forward () method works at servlet side.The sendRedirect () method works at client side.
It sends the same request and response objects to another servlet.It always sends a new request.
It can work within the server only.It can be used within and outside the server.
Example: request. getRequestDispacher ( “servlet2” ) . forward (request, response) ;Example: response. sendRedirect ( “servlet2” ) ;
  • Syntax of < jsp: forward > without parameter:

    < jsp: forward page = “relativeURL <% = expression %>” / >

  • Syntax of < jsp: forward > with parameter:

    < jsp: forward page = “relativeURL <% = expression %>” >

    < jsp: param name = “parametername” value = “parametervalue <% = expression %>” / >

    < /jsp: forward >

  • Syntax of sendRedirect () method:

Public void sendRedirect (string URL) throws IOException;

Developed by: