tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Anderson <jim_ander...@centurylink.net>
Subject My problem: I cannot successfully get or set a session attribute from a JSP file.
Date Sat, 06 Dec 2014 21:19:10 GMT

Hi to all,

I am currently developing some server side JSP code. By and large, 
things are progressing and working well. I have gotten half way decent 
at debugging my java/javascript/jquery/jsp/HTML source code, but I have 
run into a problem in JSP where the code does not work, but I have found 
no clues as to why it is not working.

The environment that I am working in is Tomcat 7.0.54 and I am using 
java 1.8 and jquery 1.7.2.

What I am trying to do:

I have html code with an embedded javascript that runs jquery code. The 
jquery code being run makes an ajax call to a JSP file on the server 
side, which I will call s.jsp. This file is a very simple file whose 
sole function is to take a registration name and query an SQL database 
to see if the name has already been used at the web site. The 
registration name is passed with a method call that looks like this:

         regName = request.getParameter("registrationName");    [item 1]

This all works fine for me. So far so good. If the registration name is 
good, the state of my application logic changes. I guess there are 
multiple ways to store state, but I have chosen to store the state as a 
session variable.  I searched the net and found an example of JSP code 
that uses the session object to store information as an attribute with a 
statement that looks something like:

         session.setAttribute("logicState","nameValidated"); [item 2]

I tried adding this line and when I now push the submit button of my 
HTML form, which calls s.jsp as an action, the application hangs (in 
firefox). I receive no error messages anywhere. Usually, when I add bad 
code in s.jsp I will get a stacktrace from firefox or error messages in 
the firefox debug console, or both. Or I will error message in my own 
homegrown debug code, but that does not happen. I know that my home 
grown code does not get called, so I can infer that the call to s.jsp is 
never made, but I cannot be 100% certain of this. I also checked my 
tomcat/logs directory and there was nothing in the log files that I 
would not expect.

So my first question is:  Can I simply add item 2, above, to my jsp file 
and expect that tomcat will recognize that I am referencing the session 
object?  In s.jsp, item 1, above, references the request object and 
tomcat handles that and I am expecting that it will also hand my 
reference to the session object.

My second question is more general. My code is not working and there are 
no error messages. Can anyone speculate why this would be the case?  Is 
there any   place else I should be looking for error messages?

Jim A.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message