Get your CodeRanch badge!*
The moose likes Servlets and the fly likes how to call jsp page from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to call jsp page from servlet" Watch "how to call jsp page from servlet" New topic
Author

how to call jsp page from servlet

Rupa Katkar
Ranch Hand

Joined: Aug 12, 2009
Posts: 35
I want to call jsp page in my servlet
How should i call that.

Please give me reply.. urgently
Anuj Prashar
Ranch Hand

Joined: Apr 15, 2008
Posts: 99

use this ..

RequestDispatcher req=request.getRequestDispatcher("/path of your jsp");
req.forward(request, response);


SCJP 5,SCWCD 5, RHCT
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Call it from your service[doGet or doPost]


instead of request ,you can use ServletContext to get requestdispatcher.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

uha.. Anuj beat me here
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

Hi Rupa,

Your question is little bit tricky... but any way use




Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Nishan Patel wrote:
Your question is little bit tricky...


Hi Nishan , How this question is tricky ? can you explain ?
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

I want to call jsp page


here you are dispatch your request to your Jsp page.... So, form servlet you pass request to your Jsp page...

so question look likes how to dispatch or pass request form servlet to jsp...
Anuj Prashar
Ranch Hand

Joined: Apr 15, 2008
Posts: 99

@seetharaman venkatasamy

lol
Rupa Katkar
Ranch Hand

Joined: Aug 12, 2009
Posts: 35
Nishan Patel wrote:Hi Rupa,

Your question is little bit tricky... but any way use








Thank you to all
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Nishan Patel wrote:So, form servlet you pass request to your Jsp page...


fine. any way after dispatch to the jsp,again the execution flow back to the servlet .
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

fine. any way after dispatch to the jsp,again the execution flow back to the servlet .


yes...but not same servlet it's depending on requirement .... flow looks like Jsp -> Servlet -> Jsp
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Nishan Patel wrote: .... flow looks like Jsp -> Servlet -> Jsp


i am mentioned about



sorry , if i didnt mentioned clearly
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to call jsp page from servlet
 
Similar Threads
how to send cookie from one jsp page to another jsp page or to servlet
Login Page creation help
jsp
Displaying images on JSP page
JSP to Servlet call