• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Include in Servlets

 
Subbu Viswanathan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have many JSP pages. Each page includes a Login Validation JSP page that would verify the user's idle time. If the user is idle for more than 5 minutes, he will be forced to login again.
I have a Servlet, that is called from one of the JSP's. How can the Login Validation JSP page be included in the Servlet?
eg.,
These are the files that I have
A.JSP, LoginValidate.JSP and Servlet1
A.JSP
-----
.....
.....
<%@include file = "LoginValidate.jsp"%>
.....
How can the same jsp page be included in Servlet1?
Any suggestions please.
Thanks
 
Cynthia Yao
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use requestdispatch.include, check the servlet api for details
 
Poornima Shetty
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use the requestdispatcher to include any jsp along with the request and response object as below:
getServletConfig().getServletContext().getRequestDispatcher("/directory/jspname that you want to include").include(request,response);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic