Forums Register Login

Calling JSP from Servlet

+Pie Number of slices to send: Send
Hi
I am tring to call a JSP page from the servlet. I have written the follwing code. The request is not forwared to the JSP. and the control remains in the servlet.
try {
// Set the attribute and Forward to UserLogin.jsp
RequestDispatcher rd =
getServletConfig().getServletContext).getRequestDispatcher("/jsp/UserLogin.jsp");
// forward the request and response to target
rd.forward(request,response);
return;
} catch (Exception ex) {
System.out.println("Caught Exception in Sending jpspage im Main Servlet : " + ex.getMessage());
}
+Pie Number of slices to send: Send
Hai!
Try by removing getServletConfig() part..
Rgds
Manohar
+Pie Number of slices to send: Send
 

Originally posted by Manohar Karamballi:
Hai!
Try by removing getServletConfig() part..
Rgds
Manohar


Hi manohar
This still does not work.
Amit
+Pie Number of slices to send: Send
What Exception is thrown (if any)?

+Pie Number of slices to send: Send
Hi Amit
I was just going through your code.Why have you written the return statement after the rd.forward(request,response); statement.Another thing.....I do not know if its a typing error on your part while sending the post or its an error in ur code...but your getServletContext() method is missing the starting bracket.As Mike said do you get any exceptions?
Regards
sanj
[This message has been edited by sanj singh (edited December 17, 2001).]
+Pie Number of slices to send: Send
 

Originally posted by Amit Lonkar:
Hi
I am tring to call a JSP page from the servlet. I have written the follwing code. The request is not forwared to the JSP. and the control remains in the servlet.


How about trying:
String dispatchto = "MyJsp.jsp";
RequestDispatcher dispatch = null;
response.encodeURL(dispatchto);
dispatch = request.getRequestDispatcher(dispatchTo);
dispatch.forward(request, response);
It's feeding time! Give me the food you were going to give to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 915 times.
Similar Threads
jsp:useBean standard action doubt
org.apache.jasper.JasperException: java.lang.ArrayIndexOutOfBoundsException: 8
Request dispatcher
IllegalStateException: Cannot Forward(Servlet 2.3, SRV 8.4)
Exception when calling jsp from servlet p/s help!
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:12:06.