• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat Madness

 
Paid O'Cuana
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've put together a web app with a MySQL Db on my local computer, using JSP with Jakarta-Tomcat-3.2.3. All works fine. I've now transferred it over to the company server, under Jakarta-Tomcat3.3. This caused problems with the MySQL driver initially (I had to have the jar file in a different directory), and now I've got more problems.
To log-in, I have customerLogin.jsp. This submits to validateLogin.jsp. If the login is invalid, this is displayed in validateLogin.jsp. If valid the user is re-diredted to "administrator.jsp" or "customer.jsp", depending on the type of user. Now, the INVALID login process works fine, but when I log in properly, I get "The page cannot be found", even though all 3 of the relevent JSPs are there in the relevent directory.
<jsp:useBean id="customerProfileBean" scope="session" class="customerProfile.customerProfileBean" />
<%
String validUser = null;
validUser = customerProfileBean.validateUser(username,password);
String isAdmin = null;
if(validUser!=null)
{
isAdmin = customerProfileBean.isUserAdmin(username);
session.setAttribute("userType",isAdmin);
System.out.println("User Type is "+isAdmin);
session.setAttribute("user",username);
String ls_session_id = session.getId();
if (isAdmin.equals("admin"))
{
String ls_encode_url = response.encodeURL("administrator.jsp");
response.sendRedirect("administrator.jsp");
}
else
{
String ls_encode_url = response.encodeURL("myLucidity.jsp");
response.sendRedirect("myLucidity.jsp");
}
}
else{
//And here I throw in the HTML for Invalid login and giving the user another chance to login
}
What could be wrong? It's driving me mental!
 
HanMing Low
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm not sure if this actually help.
But you can definitely try to check the url you reference to.
e.g.
response.sendRedirect("administrator.jsp");
You can try
response.sendRedirect("./administrator.jsp");
or
response.sendRedirect("http://server/dir/administrator.jsp");
I previously had similar problem with Tomcat on different distribution.
i.e.
Tomcat from JBuilder and Tomcat from Jakarta response differently to the url.
So, you can try it out.
Hope it helps.
Cheers.

Han Ming
 
Paid O'Cuana
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers, HanMing - it worked nicely.
Stupid computers.
 
Paid O'Cuana
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I have another problem with regard to this stuff.
When I log on in Tomcat3.2.3, I set a session variable "userType" to, obviously, identify what type of user it is.
isAdmin = customerProfileBean.isUserAdmin(username);
session.setAttribute("userType",isAdmin);
Then in the next JSP, I do this:
String userType = null;
userType = (String)session.getAttribute("userType");
And that gets the user type for me. Works grand on my computer in tomcat3.2.3. But on the company server using tomcat3.3, I get a null pointer exception when I try to use the "userType" variable:
if (userType.equals("admin"))
{
szUser = request.getParameter("user");
}
Is there a difference in the way sessions are used?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!