How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...
using RequestDispatcher..its not possible..becoz
RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
rd.foward(req,res);
Here the request and response are null objects..
So mi question can frame as how can i get request/response in servlet's init method()..
thanx in advance..
Discussions
Web tier: servlets, JSP, Web frameworks: How can i redirect to my jsp page from servlet in init() method.
-
How can i redirect to my jsp page from servlet in init() method. (1 messages)
- Posted by: Ramprasad Maganti
- Posted on: November 14 2002 04:16 EST
Threaded Messages (1)
- How can i redirect to my jsp page from servlet in init() method. by Klaas van der Ploeg on November 14 2002 07:54 EST
-
How can i redirect to my jsp page from servlet in init() method.[ Go to top ]
- Posted by: Klaas van der Ploeg
- Posted on: November 14 2002 07:54 EST
- in response to Ramprasad Maganti
You cannot do that from the init() method.
A client request (ie from a browser) is coming to your servlet's service method. This service method will call doGet(req,res) or doPost(req,res) or others depending on the request method (GET,POST,HEAD,etc..)
So, you can only redirect when a request has been made (ie your servlet is called from the browser). To redirect from doGet or doPost, use the method you described.
Rgrds,
Klaas