Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening webpages

Status
Not open for further replies.

djam

Technical User
Nov 15, 2002
223
CA
I have 2 web pages; one is a login page were the user types in his id & password and then presses the submit button to login. The other page is the one that should appear right after the login page. I have a class called Login.java in which I check the id & password for verification purposes and then I obtain a PrintWriter object and use its println method to display the next page. However, what I'd like to do is simply to load up the next page without printing its HTML code through the println method. Is there a method in the Servlet package that simply opens/loads the web page that I have already created?

Thanks! " ahhh computers, how they made our lives much simpler ;) "
 
Yes, there is a way to do that. To Include say another JSP page from a servlet you can use something called RequestDispatcher from the ServletContext. Here is an example.

We are in a servlet, we want to include a page called test.jsp to the output stream. we'd do this...

ServletContext servletcontext = getServletContext();
RequestDispatcher requestDispatcher = servletcontext.getRequestDispatcher("/test.jsp");
requestDispatcher.include(request,response);

Hope that helps, if you are still having issues try googling INCLUDE WEB PAGE INSIDE SERVLETS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top