ATTACHMENT part 3 message/rfc822
> Subject: Re: VERY VERY URGENT.SESSION TIME OUT
> PROBLEM WHEN USING COOKIES ALONG WITH
> SESSION
> To: [EMAIL PROTECTED]
> From: [EMAIL PROTECTED]
> Reply-to: A mailing list about Java Server Pages
> specification and reference
> <[EMAIL PROTECTED]>
> Date: Sat, 5 May 2001 04:12:23 -0700
>
> --- Patrick Fong <[EMAIL PROTECTED]> wrote:
> > post your code.
> >
> > P.
> Hi Fong, This is my sample Code
> --------------------------------
> This is the sample code.All the Pages will use the
> same sort of code.
>
----------------------------------------------------------------------
> <HTML>
> <HEAD>
> <SCRIPT language = "JavaScript" SRC =
> "../../resource/AlertMessages.js">
> </SCRIPT>
>
> <TITLE>Web Time Sheet - Task List</TITLE>
> <LINK href="../../resource/style1.css"
> rel=stylesheet
> type=text/css>
> <META content=no-cache >
> </HEAD>
> <BODY>
> <%@ page buffer="16k" autoFlush="true" %>
>
> <%@ include file="../login/AdminSession.jsp" %>
> <%@ page errorPage="../ErrorPage.jsp" %>
> <%@ page import="java.sql.ResultSet" %>
> <%@ page import="java.sql.ResultSetMetaData" %>
> <%@ page import="com.klatencor.wts.TaskMaster" %>
> <jsp:useBean id="task"
> class="com.klatencor.wts.TaskMaster"
> scope="application" />
> <%@ page import="java.net.URLEncoder"%>
> <%@ page import="java.net.URLDecoder"%>
> <% String homePage = "ListTask.jsp";%>
> <% String tableName = "TASKMASTER"; %>
> <%
> ResultSet resultsetForTask = null;
> Cookie cookies[] = request.getCookies();
> String cookieName = null;
> String orderByColumn =
> request.getParameter("orderByColumn");
> String columnName = request.getParameter("column");
> String condition =
> request.getParameter("condition");
> String Value = request.getParameter("Value");
> for( int cookieIndex = 0; cookieIndex <
> cookies.length; cookieIndex++ )
> {
> cookieName = cookies[cookieIndex].getName();
> if( orderByColumn == null && cookieName.equals(
> "TaskOrder" ) )
> {
> orderByColumn = cookies[cookieIndex].getValue();
> }
> if( columnName == null && cookieName.equals(
> "TaskFilterColumn" ) )
> {
> olumnName = cookies[cookieIndex].getValue();
> }
> if( condition == null && cookieName.equals(
> "TaskFilterCondition" ) )
> {
> condition = cookies[cookieIndex].getValue();
> }
> if( Value == null && cookieName.equals(
> "TaskFilterValue" ) )
> {
> Value = cookies[cookieIndex].getValue();
> }
> }
> if(Value==null)
> {
> Value="";
> }
> Value = URLDecoder.decode(Value);
> // this variable is used by the filter page so it
> should not be removed
> String filter = columnName + " " + condition + " " +
> Value;
> Cookie orderByCookie = new Cookie("TaskOrder",
> orderByColumn);
> orderByCookie.setMaxAge(60*60*24*90);
> Cookie filterColumnCookie = new
> Cookie("TaskFilterColumn", columnName);
> filterColumnCookie.setMaxAge(60*60*24*90);
> Cookie filterConditionCookie = new
> Cookie("TaskFilterCondition", condition);
> filterConditionCookie.setMaxAge(60*60*24*90);
> Cookie filterValueCookie = new
> Cookie("TaskFilterValue", URLEncoder.encode(Value));
> filterValueCookie.setMaxAge(60*60*24*90);
> response.addCookie(orderByCookie);
> response.addCookie(filterColumnCookie);
> response.addCookie(filterConditionCookie);
> response.addCookie(filterValueCookie);
> String taskName= "";
> %>
> <%@ include file="../shared/ListFilter.jsp" %>
> <FORM method="POST" name="ListForm">
> <input type="hidden" name="code" value="123">
> <input type="hidden" name="state" value="123">
> <DIV class=docHeader>List of Tasks</DIV>
> </FORM>
> <FORM method="POST" name="ListTaskForm">
> <TABLE class=form Align = "left" >
> <TBODY>
> <TR>
> <TD class=title colSpan=4 ><A HREF =
> "ListTask.jsp">Task List</A></TD>
> </TR>
> </TR>
> </TBODY>
> </TABLE>
> </FORM>
> </BODY>
> </HTML>
>
>
> This the code for AdminSession.jsp:
> -----------------------------------
> <% session = request.getSession(false); %>
> <% if (session != null) { %>
> <% String code =
> (String)session.getAttribute("usertype"); %>
> <% if((code != null) &&
> (code.equalsIgnoreCase("admin"))) { %>
> <% if((System.currentTimeMillis() -
> session.getLastAccessedTime()) >=
> (session.getMaxInactiveInterval())) { %>
> <% session.invalidate(); %>
> <jsp:forward page="../../jsp/login/SessionError.jsp"
> />
> <% } %>
> <% } else { %>
> <jsp:forward page="../../jsp/login/SessionError.jsp"
> />
> <% } %>
> <% } else { %>
> <jsp:forward page="../../jsp/login/SessionError.jsp"
> />
> <% } %>
>
> This the code for Session.jsp:
> ------------------------------
> <HTML>
> <HEAD>
> /HEAD>
> <BODY>
> <%@ page import="java.sql.ResultSet" session="true"
> %>
> <%
> session = request.getSession(true);
> if(session != null)
> {
> session.setAttribute("username", user);
> session.setAttribute("usertype", userCode);
> session.setMaxInactiveInterval(30*60*1000);
> %>
> <jsp:forward page="Main.jsp" />
> <%}
> %>
> <H5>
> <p>Enter a Correct Login and Password</P>
> <p>Reasons may be the Following:</p>
> <p>Your LoginNme,Password may be Incorrect(Password
> should be Typed in correct case)<br>
> Or Your joining / leaving dates restricts your
> entry</p>
> <jsp:include page="/html/LoginScreen.html"
> flush="true"/>
> <%}%>
> </BODY>
> </HTML>
>
> >
> >
>
_________________________________________________________________________
> > Get Your Private, Free E-mail from MSN Hotmail at
> > http://www.hotmail.com.
> >
> >
>
===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with
> > body: "signoff JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with
> body:
> > "set JSP-INTEREST DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found
> at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> >
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >
>
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>
> __________________________________________________
> Do You Yahoo!?
>
=== message truncated ===
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets