Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Servlets and the fly likes Include in Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Include in Servlets" Watch "Include in Servlets" New topic

Include in Servlets

Subbu Viswanathan

Joined: May 15, 2001
Posts: 8
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?
These are the files that I have
A.JSP, LoginValidate.JSP and Servlet1
<%@include file = "LoginValidate.jsp"%>
How can the same jsp page be included in Servlet1?
Any suggestions please.
Cynthia Yao
Ranch Hand

Joined: Nov 06, 2000
Posts: 92
use requestdispatch.include, check the servlet api for details
Poornima Shetty

Joined: Dec 12, 2000
Posts: 26
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);
I agree. Here's the link:
subject: Include in Servlets
jQuery in Action, 3rd edition