• Post Reply Bookmark Topic Watch Topic
  • New Topic

Parameters  RSS feed

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!!
I'm new in JSP's so I need a lot of advice..
I'm trying to validate a user from a JSP, asking for an id_user, and a password. For validation I had accessed the database thru a class called : CL_Conection that I imported.. but my problems become after I validate the user:
[*]when I try to open a new navigator window (which the user has the permission to see) and close the existing one.
[*]when I try to pass (parameter) the id_user to the new navigator window (that could be another jsp?)
I don't want to pass the parameter thru the URL because I have heard it's not safe.. So, is there another way to pass the parameter to another JSP?
Help me please!!
What do I need to do to solve these problems?
Could you give me a hint with some code?
Thank you very much!!
Nancy.
 
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your problem could be that your new window doesn't have access to the session the origional window has.
Why open a new window and close down the original? Why not just forward onto a new page in the same window??
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And why not use a session to store the information you need, instead of using a URL?
Erik
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right! Maybe I don't need to open a new window, so I have to do:
pageContext.forward("validaError.jsp");
to load another jsp in the same window, don't I?
But, how can I access the form's components of the first JSP? because I need to know the id_user that is in the first one JSP...
How can I implement the sesions? (code)
Help!! or if you want, could you give me some links to JSP pages (no SUN) to learn more?
Thanks in advance...
Nancy.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nancy,
I have given a sample code for validating and storing values in session.

<%
String login = request.getParameter("login");
String passwd = request.getParameter("passwd");


try
{
if(cl_connection.validate(login,passwd)==true)
{

session.putValue("Login",login);
response.sendRedirect("http://..../somepage.jsp");

}
else
{
response.sendRedirect("http://.../login.jsp);
}
}
catch(Exception e)
{
out.println("Exception :"+e.toString());
}
%>

In subsequent pages just use
String str_Login =(String)session.getValue("Login");
to retrieve the Login.
U can put as many values in session which can be available throughout the user session.
When the user logs off use session.invalidate();
to clear all the values from the session.
Hope this solves ur problem.

"Life is too Wonderful to be Spent worrying"
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!