| Author |
Facing Issue in implementing Listeners and Filters
|
Mohit G Gupta
Ranch Hand
Joined: May 18, 2010
Posts: 634
|
|
I have coded a small example that shows various listeners and filter invocation.
The issues are:
1. I am unable to see any of the system.out.println in listeners and filters on the console except
i)Value bound
ii)user nto in role
2.The getRemoteUser() isnt returning "max".
The input to form is username:max password:max for authentication as defined in web.xml and the input to Welcom.jsp are max and eassy .
The servlet check if the username and password are same as defined in database and upon correct login forwards request to other JSP
I am using Eclipse Helios and tomcat server 5.5 .
please do tell where to see tomcat logs.
Files are:
web.xml
listeners:
Employee
HttpSessionAttributeListener
HttpSession
ServletContexxt
Servlets:
Sign
filters
LoginFilter
Welcom.jsp
Output on Console:
Oct 9, 2011 12:48:40 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_23\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Java\jdk1.6.0_23\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Graphviz2.26.3\bin;C:\Program Files\Java\jdk1.6.0_23\bin;C:\TCWIN45\BIN
Oct 9, 2011 12:48:40 PM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Oct 9, 2011 12:48:40 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 393 ms
Oct 9, 2011 12:48:40 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Oct 9, 2011 12:48:40 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.31
Oct 9, 2011 12:48:40 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Oct 9, 2011 12:48:41 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Oct 9, 2011 12:48:41 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Oct 9, 2011 12:48:41 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/17 config=null
Oct 9, 2011 12:48:41 PM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Oct 9, 2011 12:48:41 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 413 ms
user in nto filter
Value Bound
|
OCPJP 6.0 93%
OCPJWCD 5.0 98%
|
 |
Niiraj Patel
Ranch Hand
Joined: Sep 17, 2011
Posts: 34
|
|
Mohit,
Please dont use class names from Servlet API. It creates confusion while reading.
Try to remove other code from your servlet and filter.
Try to include code which is related to this thread only.
So anyone can read it easily.
Please resubmit your code.
Thanks,
Niraj
|
 |
Mohit G Gupta
Ranch Hand
Joined: May 18, 2010
Posts: 634
|
|
I have corrected the code Niraj.
Please Help.
|
 |
Mohit G Gupta
Ranch Hand
Joined: May 18, 2010
Posts: 634
|
|
Hi fellow ranchers,
Please provide a solution for the problem.
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1043
|
|
Hi,
There is a lot of code to digest, also code not relevant to your problem that is why people probably didn't give you an answer immediatly.
First of all, correct the mistakes in your web.xml:
should be
and should be
Secondly: I couldnot get it working because of the <user-data-constraint>, did you do anything to the Tomcat settings (like enable SSL-port?)
Thirdly: your Welcom.jsp is protected and once you are in it you have a sort of login-form again: any reason for that? The username and password are not used by the standard JEE security, if you want that you have to use form-login like this:
and a web.xml entry like this
Regards,
Frits
|
 |
Mohit G Gupta
Ranch Hand
Joined: May 18, 2010
Posts: 634
|
|
I have made modification to web.xml and LoginFilter.
Still, I am unable to see any of the system.out.println in listeners and filters on the console except
i)Value bound
ii)user nto in role
web.xml
LoginFilter,
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1043
|
|
You didn't answer my question about your login page....
How far did you check the flow of your application? Did you get into your Sign Servlet? If so, add a System.out.println() in the catch statement and see if it gets there.
What do you expect to happen, because you only give code without further explanation?
Regards,
Frits
|
 |
Mohit G Gupta
Ranch Hand
Joined: May 18, 2010
Posts: 634
|
|
i added the login page as I was trying different security mechanism for the servlet.
Anyways,Thanks Frits i got the code working.
|
 |
 |
|
|
subject: Facing Issue in implementing Listeners and Filters
|
|
|