• 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

Login bean help

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have seen talk about using beans for logging into a website and here is what I have pieced together so far. Questions at the end!
Bean:
=====
public class UserLogin {
private boolean loggedIn = false;
public UserLogin() { }
public void setLogin(String user, String pass) {
// Validate login correct here and set to true or false
loggedIn=true;
}
public boolean validUser() {
return loggedIn;
}
}
settup bean after login.html
============================
// loaded from the login.jsp page via a form.
<%@ page import = "UserLogin" %>
<jsp:useBean id="c" scope="session" class="UserLogin">
</jsp:useBean>
<% c.setLogin(request.getParameter("username"),request.getParameter("password") ; %>

Code on everypage to verify they user has logged in
====================================================
<jsp:useBean id="c" class="UserLogin" scope="session" />
<% if (!c.validUser()) response.sendRedirect("login.jsp"); %>

Questions:
Is this code going to run, or is there something I am missing.
What do I need to added to the web.xml file for Tomcat 4 to run this.
Any guidance or examples or helpful websites would be great. Thanks!!!
Dean
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic