• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems writing a login filter using getRemoteUser() method

 
Ranch Hand
Posts: 222
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you casting the parameter and then ignoring the cast?
 
Jay Tai
Ranch Hand
Posts: 222
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 222
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. Problem solved!
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic