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!

User Validation JSP on Tomcat

Status
Not open for further replies.

Vadim

Programmer
Feb 5, 2002
75
US
I have a user authentication JSP that check users against some file and return info if they may or may not see selected application.

Early, I have a small number of such pages and added that user validation code to each checked page. Now, I need to add it to almost all my pages.
Is it possible to involve signon.jsp program globaly for
any page requered from server when session expired?


//-------------MyApplication.jsp ------------------------
....
// Authentication section
String sStrAllowed = null;
if(session.getAttribute("USER")==null)
{
Enumeration en = request.getParameterNames();
String sParam =null;
String sPrmValue = null;
String sTarget = "SignOn.jsp?TARGET=MyApplication.jsp";
StringBuffer sbQuery = new StringBuffer() ;

while (en.hasMoreElements())
{
sParam = en.nextElement().toString();
sPrmValue = request.getParameter(sParam);
sbQuery.append("&" + sParam + "=" + sPrmValue);
}
response.sendRedirect(sTarget + sbQuery.toString());
}
else
{
sUser = session.getAttribute("USER").toString();
sStrAllowed = session.getAttribute("STORE").toString();
}
.....
//---------------------------------------------

 
You can include a JSP within a JSP like this :

Code:
<%@ include file ="header.inc" %>

You may perform custom operations when a session is created or expires by implementing the HttpSessionListener and registering it in your web.xml :


Example on how to do it :


--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top