M
Mladen Adamovic
In mysql I have table members(mem_id,mem_password,...).
I want to make login to my web application (jsp/servlet/html) using
information from table members.
1. Is there good prepared login solution which is easily to use with tomcat
4/ant? (I could change to EE if its neccessery)
2. I tried to write some login code, but I have problems.
First, let me explain what I'm trying to do: in Authorize.java i set two
attributes of its ServletContext then forward using RequestDisplather to the
Home.jsp, in Home.jsp I read those attributes - and they are null.
Some code follows:
//SOME CODE FROM Authorize.JAVA servlet:
...
ServletContext sc=getServletContext();
sc.setAttribute("mem_id",id);
sc.setAttribute("mem_passwd",pass);
System.err.println("In Authorize.JAVA User connected: "+id);
...
RequestDispatcher dispatcher =
req.getRequestDispatcher("/Home.jsp");
if (dispatcher != null)
dispatcher.forward(req, res);
...
//END OF Authorize.java
//SOME CODE FROM Home.jsp
String mem_id=(String) session.getAttribute("mem_id");
String mem_pass=(String) session.getAttribute("mem_passwd");
if(mem_id==null || mem_pass==null)
{
//user is not connected, ask for id and pass
System.err.print("in Home.jsp user is not connected - ");
System.err.println("mem_id: "+mem_id+" mem_passwd :"+mem_pass);
...
//END OF Home.jsp
On the console I got the following :
In Authorize.JAVA User connected: root
in Home.jsp user is not connected - mem_id: null mem_passwd :null
Where I'm wrong?
Thanks in advance.
I want to make login to my web application (jsp/servlet/html) using
information from table members.
1. Is there good prepared login solution which is easily to use with tomcat
4/ant? (I could change to EE if its neccessery)
2. I tried to write some login code, but I have problems.
First, let me explain what I'm trying to do: in Authorize.java i set two
attributes of its ServletContext then forward using RequestDisplather to the
Home.jsp, in Home.jsp I read those attributes - and they are null.
Some code follows:
//SOME CODE FROM Authorize.JAVA servlet:
...
ServletContext sc=getServletContext();
sc.setAttribute("mem_id",id);
sc.setAttribute("mem_passwd",pass);
System.err.println("In Authorize.JAVA User connected: "+id);
...
RequestDispatcher dispatcher =
req.getRequestDispatcher("/Home.jsp");
if (dispatcher != null)
dispatcher.forward(req, res);
...
//END OF Authorize.java
//SOME CODE FROM Home.jsp
String mem_id=(String) session.getAttribute("mem_id");
String mem_pass=(String) session.getAttribute("mem_passwd");
if(mem_id==null || mem_pass==null)
{
//user is not connected, ask for id and pass
System.err.print("in Home.jsp user is not connected - ");
System.err.println("mem_id: "+mem_id+" mem_passwd :"+mem_pass);
...
//END OF Home.jsp
On the console I got the following :
In Authorize.JAVA User connected: root
in Home.jsp user is not connected - mem_id: null mem_passwd :null
Where I'm wrong?
Thanks in advance.