Variables problem
It seems that when two users (two sessions) request concurrently the same JSP, variables in JSP will change depend on the session that sets the variable later.
Ex: I have a JSP named Login.jsp with two parameters: username and password. Two user will submit with different username and password. One is valid and other is invalid and should be rejected. However both are valid and login the system with the same valid username and password.
<%@ page import="app.*,java.sql.*,java.util.*,java.text.*,java.io.*,java.lang.*" contentType="text/html;charset=WINDOWS-1252" %>
<jsp:useBean id="dbConnection" class="app.DbConnection" scope="session"/>
<jsp:useBean id="appLogin" class="app.APPLogin" scope="session"/>
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="Oracle JDeveloper">
<TITLE>
Test
<%
response.setDateHeader("Expires",0);
response.setHeader("Pragma","no-cache");
if(request.getProtocol().equals("HTTP/1.1")){
response.setHeader("Cache-Control","no-cache");
}
%>
</TITLE>
</HEAD>
<BODY>
<%!
Connection c;
String username = "";
String password = "";
String tt_username="";
String dd_firstpage="";
long dd_count=0;
%>
<%
dbConnection.setConnectionDefault();
c = dbConnection.getConnection();
username = request.getParameter("username");
password = request.getParameter("password");
...
[1588 byte] By [
minhhoa] at [2007-9-26 2:43:01]

hi,you defined the username,password variables as class variable,so maybe you can get the problem.
below is my code,you can see:
//lsh02.jsp
<%!
String username = "";
String password = "";
String tt_username="";
String dd_firstpage="";
long dd_count=0;
%>
when execute the lsh02.jsp,servlet engineer will transform the jsp code to java code,it's java code is:
package lsh;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.Vector;
import org.apache.jasper.runtime.*;
import java.beans.*;
import org.apache.jasper.JasperException;
public class _0002flsh_0002flsh_00030_00032_0002ejsplsh02_jsp_0 extends HttpJspBase {
// begin [file="D:\\tomcat\\webapps\\ROOT\\lsh\\lsh02.jsp";from=(0,3);to=(6,0)]
String username = "";
String password = "";
String tt_username="";
String dd_firstpage="";
long dd_count=0;
// end
static {
}
public _0002flsh_0002flsh_00030_00032_0002ejsplsh02_jsp_0( ) {
}
private static boolean _jspx_inited = false;
public final void _jspx_init() throws JasperException {
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
String _value = null;
try {
if (_jspx_inited == false) {
_jspx_init();
_jspx_inited = true;
}
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html;charset=8859_1");
pageContext = _jspxFactory.getPageContext(this, request, response,
"", true, 8192, true);
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
} catch (Exception ex) {
if (out.getBufferSize() != 0)
out.clearBuffer();
pageContext.handlePageException(ex);
} finally {
out.flush();
_jspxFactory.releasePageContext(pageContext);
}
}
}
you can see that the username,password all are class variable,when the servlet is mulitthread,the problem will occurs.suggest you define the variable as local variable.