It's not a secret anymore!*
The moose likes Servlets and the fly likes Call JSP page from a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Call JSP page from a Servlet" Watch "Call JSP page from a Servlet" New topic
Author

Call JSP page from a Servlet

swati bannore
Ranch Hand

Joined: Oct 18, 2000
Posts: 201
Hello Friends,
I have a problem.I have a servelt say CheckLogin.java and a JSP file named EmployeeView.jsp.My servlet is validaing the username and password and based on those results I need to call my JSP file which displays the details of the employee.
How do I call a jsp file from this Servlet??
Can anybody help me??
Thankx
Swati


Swati Kale
SCJP
SCWCD
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Swathi,
I use this practice and found useful. I wrote a method called gotoPage in a utility file called ServletUtilities.java and made it static. Whenever I want to route the response to some resource I just call ServletUtilities.gotoPage(....); One more advantage is in goToPage method I use encodeURL. So if I want to encode/de-encode all the routed urls, just change in only one method gotoPage and it is reflected in WHOLE web appln. Also note that the url which we give to gotoPage(...) is relative web url with respect to the web appln.
regds
maha anna

[This message has been edited by maha anna (edited October 18, 2000).]
swati bannore
Ranch Hand

Joined: Oct 18, 2000
Posts: 201
Thanxx Maha,it did work and
even response.sendRedirect(EmployeeView.jsp) works fine!
Swati
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Call JSP page from a Servlet
 
Similar Threads
Problem seeing my servlet from JSP
uploading a file using jsp
jsp/servlet/container relationships
Login Page creation help
Calling .js file from Java