File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
Similar Threads
Finding current URI?
Count of servlet file
Form Variables
Difference JSP File & JSP Page
include action vs. include directive