• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Facing Issue in implementing Listeners and Filters

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have corrected the code Niraj.
Please Help.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi fellow ranchers,

Please provide a solution for the problem.
 
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i added the login page as I was trying different security mechanism for the servlet.
Anyways,Thanks Frits i got the code working.
 
My first bit of advice is that if you are going to be a mime, you shouldn't talk. Even the tiny ad is nodding:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic