Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

check if user is login or not

jsp servlets login index user

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 game2d

game2d

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 57 posts

Posted 16 December 2013 - 10:57 PM

I have a index page of my website. it will change if user is login or not. I know how to do just by using jsp. but this is not the right way bc I am using java code in html file.
 
so here is ex of doing it just by jsp
index.jsp
<html>
<body>
<%
if (session.getAttribute("username") != null) {
out.print("
                            <div>
                                     user | option | logout
                              </div>      
                            ");
} else {
out.print("
                         <div>
                              login | forgotpassword | create account
                          </div>");
}
%>
</body>
</html>
 
 
so I want to do the same thing only doing it by the right way(jsp/servlets). I tried look up but cant find any thing.

Edited by Roger, 17 December 2013 - 11:18 AM.
edited topic tags


#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 20 December 2013 - 11:07 AM

You might start to learn how to do it with this simple example