Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HELP !!! - How can I call a JSP from a servlet???

 
Catriona McCann
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a JSP which is basically a welcome screen. This JSP calls a servlet to extract some information from a DB. I would then like to call another JSP from the servlet and write to the fields in the JSP. How can I do this.
Thanks in advance !!!
Catriona.
 
parul jain1
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

forwardFileName = "/jsp/"+"homepage"+".jsp";
getServletConfig().getServletContext().getRequestDispatcher(forwardFileName).forward(req, res);
return;
 
bob walker
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also do a servlet re-direct to your jsp.
Use the HttpServiceResponse.sendRedirect() method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic