Jump to content

[Solved] Session.getattribute() Not Working.


patonoid

Recommended Posts

So after some playing around with my application locally and the one deployed here: http://empreenda.heliohost.org/FINAL/admin/login.jsp

I have come to the conclusion that session.getAttribute() is not working for some reason on the server.

 

 

if(request.getParameter("sair")!=null)
{
session.setAttribute("usuarioAdmin", null);
}
String msg = "";
if(request.getParameter("txtLogin")!=null &&
request.getParameter("txtSenha")!=null)
{
msg = "Tentou fazer o login";
String login = request.getParameter("txtLogin").toString();
String senha = request.getParameter("txtSenha").toString();
if(login.equals("administrador") && senha.equals("password") )
{
session.setAttribute("usuarioAdmin", login);
response.sendRedirect("categoria_listar.jsp");
}
else
{
msg = "Otário";
}
}
what should happen here is that if the user inputs the correct log in information a session.setAttribute and a redirect to a different jsp file should occur.
the header of the file redirected to has this:
if (session.getAttribute("usuarioAdmin") == null) {
response.sendRedirect("login.jsp");
}

 

which tests if the session is null and if it is, it redirects back to the login page. Note that if the wrong log in information is input a message should show and no redirect should take place.

 

after testing it locally with right and wrong log in information I can simulate both scenarios but on the deployed version for some reason i am redirected back to the login page even if I input the right log in credentials as if I had no session attribute set and no wrong log in message is displayed.

Does anyone have any idea how I could fix this and if can get the tomcat logs for this behaviour.

 

 

Link to comment
Share on other sites

Are you aware that your username gets appended to the start of the .war filename if it isn't already there? So if you submit the file FINAL.war it gets renamed to pato_FINAL.war before it's deployed. If you submit pato_FINAL.war then it stays the same. We have to append the username because otherwise only one person whould be able to deploy a file by each name. Sometimes this has caused issues for people who aren't used to running their java applications in a multi-user environment.

 

No, you may not have access to the tomcat logs because the tomcat logs contain private information pertaining to all of the java enabled accounts on the server. Granting access to view them would violate our privacy policy. I've suggested multiple times, but I'm not sure if anyone has tried it yet, to have your .war file write log files directly to your /home/pato/ directory.

  • Like 1
Link to comment
Share on other sites

I did not notice that :/ Sorry for the inconvenience. I am new to this and this my first time trying to deploy anything to the web, I have just uploaded another war file, this time its named correctly, by the way I really like how fast replies are, I will be making another donation soon (since I live in Brazil any dollar amount is kind of much), but I really hope it can help in some way.

Thank you for your patience.

Gabriel :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...