Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSP Variable Scope

843833Oct 1 2001 — edited Dec 7 2005
Hello,

I'm fairly new to JSP, so I apologize if this is a newbie question. I'm having a problem where it appears as though some variables I defined in the declaration area of my JSP page are shared by multiple clients. Here is a code snippet...

<%@ page import="java.util.*" %>
<jsp:useBean id="postSearch" scope="request" class="healthweb.PostBean" />
<%!
String hridErr = "";
String emplHrid = "";
String supvHrid = "";
String yourHrid = "";
boolean youAreEmpl = true;
boolean youAreSupv = false;
Hashtable[] empl;
Hashtable[] you;
Hashtable[] supv;
%>
<SCRIPT LANGUAGE="JavaScript">
alert("<%= request.getParameter("yHrid") %>");
alert("<%= youAreEmpl %>");
</SCRIPT>
...

As you can see, I'm initializing the youAreEmpl variable to true. However, if a client executes this JSP and the variable gets set to false, it seems to be false when other clients access the JSP initially.

I'm very confused by this. Doesn't each client receive its own scope and its own instance of the object created by the JSP page?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 4 2006
Added on Oct 1 2001
10 comments
736 views