tags:

views:

48

answers:

1

i want code to check whether the user in logged in or not. I get replied with context that to use HttpServletRequest.getUserPrincipal(). But i do not know how to set the username in servlet so that it is further called by getUserPrincipal()

Thank in advance

A: 

To get a user via getUserPrincipal, you need to authenticate using container-managed authentication. This usually (always?) involves setting security constraints and authentication mechanisms in your web.xml. There are several examples in the JEE5 tutorial. How usernames/passwords are registered is an implementation detail that will depend on the servlet container and how it is configured.

McDowell
thanks i'll try.
satya