• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems writing a login filter using getRemoteUser() method

 
Jay Tai
Ranch Hand
Posts: 221
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to write the following filter to get the user name and password after a user logs in, to store this as a session object and use the object to return user details. The problem is I can't seem to resolve the getRemoteUser method. I looked at the javax.servlet.http library and the method I need is right there, but it throws a 'cannot resolve symbol' error in the IDE (Netbeans). I always thought method classes loaded in the library can be resolved at compile time. Never seen this error before.

Why is it not possible to resolve the getRemoteUser method? Is incorrect to simply call this method using the HttpServletRequest request parameter like:

String remoteUser=request.getRemoteUser(); ?

Do I have to write a custom implementation of this method?

When I do this it fails to resolve even though I can see the getRemoteUser method in the HttpServletRequest class in my project library

Thank you!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you casting the parameter and then ignoring the cast?
 
Jay Tai
Ranch Hand
Posts: 221
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I'm not aware of how I'm ignoring the cast. I thought that by casting the parameter to type HttpServletRequest means that the parameter 'request' can use HttpServletRequest in the subsequent method call?

So would it be more appropriate to change the parameters so that I can use 'use' the cast like so?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, this is basic Java. Servlets do not act any different than any other Java code. If you want to use the result of the cast, you must use the variable that recevies the casting.
 
Jay Tai
Ranch Hand
Posts: 221
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. Problem solved!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic