Issue in applying SSL selectively to Login JSP Page--Session getting lost.

Hi,
I am facing some issues with SSL configuration on my web site running on tomcat 5.5. I am using jdk 1.5 and form based authentication with JAAS framework.
The SSL configuration is working perfectly when applied to complete web site, but starts giving problem when applied selectively to some JSP pages. At present I am trying to apply SSL just on the login page.
When the login screen loads up, the URL in the browser has a protocol "*https*", as expected, but it doesn't gets changed to "*http*" once the user has successfully logged in. Why is the automatic change from https to http not ocurring?
Also I want to know which is the default page, tomcat will direct the logged in user to, once successfully authenticated using form based login; Is there any way to change this default page to some other page. It looks like that tomcat automatically directs to index.html , once the user has been successfully authenticated, but I am not so sure. My index.html page is having 4 frames; the source of these frames are different JSP pages, which are not under SSL.
My aim is to apply SSL just on login.jsp so that password doesn't travel in clear text. Once the user is authenticated he should see index.html and the address bar's URL should change it's protocol from https to http.
Please, find below the code in my web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>CWA Application</web-resource-name>
<url-pattern>/about.jsp</url-pattern>
<url-pattern>/admin_listds.jsp</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<url-pattern>/*login.jsp*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>CWA Application</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/login.jsp?error=true</form-error-page>
</form-login-config>
</login-config>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
My login. jsp has below code:
<form name="login" method="POST" action='<%= response.encodeURL(*"j_security_check*") %>' >
<tr>
<td width="100%">
<table width="260" border="0" cellspacing="0" cellpadding="1">
<tr>
<td align="left" valign="top" rowspan="4"><img src="images/space.gif" width="15" height="5"></td>
<td align="right" class="login-user" nowrap ><p>User name: </p></td>
<td align="left" valign="top"><input maxLength="64" name="j_username" size="20"></td>
</tr>
<tr>
<td align="right" nowrap class="login-user"><p>Password: </p>
</td>
<td align="left" valign="top">
<input maxLength=\"64\" tabindex="2" type="password" name="j_password" size="20">
</td>
</tr>
</form>
The entries in my server.xml are following:
<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="${java.home}\lib\security\cacerts" keystorePass="changeit"
clientAuth="false" sslProtocol="TLS" />
I have gone through the http://forums.sun.com/thread.jspa?threadID=197150 and tried implementing it; The filter as explained in the thread does gets called but the session values are still lost.
Please note I am using javascript to go from secure "https" to "http" once the user has successfully logged in The javascript code is as below:
top.location.href="http://localhost:8080/qtv/index.html." ;
If I use response.sendRedirect("http://localhost:8080/qtv/index.html") for going to non-secure mode, the index.html page does not gets loaded properly. (Please note that my index.html is made of *4 frames*, as explained earlier. This is a legacy code and frames can't be removed).
The reason for index.html not getting loaded properly is that the Address bar URL does NOT change its URL and protocol from https (https://localhost:8443/qtv/index.html ) to "*http*" (http://localhost:8080/qtv/index.html) when esponse.sendRedirect() is used ;this is the default behaviour of response.sendRedirect(). And because the protocol in address bar is https, index.html is not able to load the other JSP's in it's frames because of cross-frame-scripting security issues (The other JSP's to be loaded in frames are are NOT secure as discussed earlier).
Please let know if any way out.
Thanks,
Masaai

Hi
try to set the maximum interval between requests
eg:
session.setMaxInactiveInterval(6000);
vis

Similar Messages

  • Login JSP losing Session

    I have a Login JSP which talks to a Servlet which then passes the login request to a Bean. In the Bean I save the login information in the Session, if the login fails I am trying to 'forward' to the Login JSP page again. On the Login JSP there is an 'errorText' field that gets the errorText Property from my Bean. However, when the 'getErrorText' method is called by the JSP I seem to have a new Session and have lost all of my login information.
    What have I done wrong ? I have tried setting the 'scope' of the Login JSP to session and the application but with no result.
    How can I ensure that when I re-display the Login JSP with an error message on it that I am using the Session (and copy of my bean) that I had when I set the properties ?
    Sarah.

    have the code for setting the session values in the servlet that comes after the JSP login page.
    in the jsp login page try to retreive the session values for the user name and the password.
    store these values in the name and password variables.
    for the first time it'll be null and an exception will be thrown. so in the catch block, set the value of the name variable and the password to null string ie "" and set these values as the values of the textfields (for user name and password). also in the catch block, set the error message string also . this one u can use to display when u r redirected to the JSP login page by the servlet. if first time, then set it to null string "".
    but assuming that the JSP page has been called from the servlet when an error occured i.e when the server cannot recognize the user name and password combination, the session variables for the user name and the password won't be null and u can use these values to be displayed in the respective textfields.
    so when the user name and password cannot be recognized by the server, just call the same JSP login page.
    hope that clears a bit of ur doubt!!
    rgds
    JP

  • Connecting to Servlet from a Login JSP page

    Hi Everyone can anyone tell how to invoke a Servlet say DBHandler servlet from a Login JSP page
    I am using JRun3.0
    If i do this i am getting an error Error 405 Resource not allowed
    The directory structure is as follows :::-----
    emtech\jsp\Login.jsp
    emtech\web-inf\classes\DBHandler.java
    in my Login.jsp page i am giving
    <form method="post" action ="DBHandler">
    </form>
    Help will be highly appreciated
    Thanking in advance
    Mumtaz
    India

    Hi
    Even after modifying i am getting the same problem
    if i use jsp:forward tag then it works fine ie transfers control fully to the servlet but if i set the form action
    like /servlet/LoginServlet or LoginServlet i get this in my url ---http://localhost:8100/emtech2/jsp/emtech2/servlet/LoginServlet
    i just am thinking of using JRun
    Plz help
    Thanking You

  • Jsp Page session vaiable to java class and vise versa

    Hi to all,
    I am new to jsp, i have to programs, one jsp page and another java class. in jsp page i get the user data from html form and put the id in session. here i have to call the session vaiable to my java class where it (variable)initialize a file name.
    and same i have to call the java class to jsp page which insert statements to sql server,
    Please Help Me.

    //My Java Class file
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import javax.servlet.http.HttpSession;
    import java.sql.Statement;
    public class StuInfo extends Object {
    //main method begins execution of Java application
    public static void main (String args[]){
    String StuFile = "C://"+iD+".txt"; // Here i have to get the session varaible.(ID)
    try {
    In my jsp Page i initilized session as
    session.setAttribute("ID",StuId);
    I am not able to understand where i have to declear the HTTPSession#getAttribute("ID");

  • How to create editable select box in jsp page

    hi,
    i got som peculiar requirement in my jsp page.i have my page like this.
    <html>
    <body>
    <form name="test">
    <select name="test">
    <option value="one">USA</option>
    <option value="two">India</option>
    <option value="three">UAE</option>
    </select>
    </body>
    </html>
    this is one of the select box in my jsp page.
    now i want to change the look and feel of select box..
    1-dont want to show the scrollbar means the right side arrow which allows to see the total options in select box.
    it should look like normal text box.
    2-roveer apert from the existing values if there is no matching value user must be allowed to enter his own value in above select box..
    how i can solve this problen..
    regards,
    sam

    Is that maybe a browser memory auto-complete thing? It works on Netscape 7.2. But no, it's not a browser auto-complete thing (does NS have that? IE does... either way, I would've disabled that). It's definitely a Javascript trick, I'm sure of that. I know I haven't sent mail to all people in my address book from my work PC, but it doesn't stop them from showing in the list as I type...
    Unless there is a special HTML tag option or browser extension that I've never heard of that allows you to supply a set of values to a text input field for auto-completion (as opposed to the browser remembering what was typed).

  • How to set the default login jsp page?

    i have written a jsp page called Login.jsp. i want it to be the default jsp page when i type the url "http://localhost:8080" , instead of the index.html of tomcat . how to make it ?

    It's in web.xml, eg. :
    <web-app>
      <welcome-file-list>
        <welcome-file>Login.jsp</welcome-file>
      </welcome-file-list>
    </web-app>

  • A text box should appear based on combo box selection in a jsp page.

    Hi,
    I have this problem. I ahve an option in the combo box"other". If other is selected then a text box shud appear . Can any one post a quick answer for me. may be a sample of how to do it will help me a lot.
    Thank You,
    Sagar.

    Hi Guys,
    Thnx all for ur replies. Let me explain u the scenario which i work in now. I have a combo box with 4 values "other " being the last of them. If i select "other" then a text box shud appear with the label. what happenes now is i have added onChange whn an option is changed . I have named that functiion refresh for which the code goes like this..
    function refresh()
    window.location.reload(true);
    whn i select an other option thn the whole page gets refreshed and the first value only appears. If i select other then the page refreshes and gets back again to the first value. These guys here use tags like <c: if> <C;choose> <c: otherwise> which am not familiar with. Do pls help me in retaining the option selected.. Thank You.

  • Login jsp pages

    hi there
    can some1 pls show me an example of a jsp login page (full) so i can refer to. i'm using tomcat, mysql and jdbc driver. thx

    http://www.javaworld.com/javaworld/jw-03-2000/jw-0331-ssj-forms.html

  • MySql select statement in jsp page

    Ok,
    I need help with this select statement.
    <%
    // Determine what option is set to.
    if(option == null || "".equals(option) || "Verify1".equals(option)){
      if("Verify1".equals(option)){
      // Retrive query specific to submitted form.
      try {
          Class.forName("org.gjt.mm.mysql.Driver").newInstance();
          conn = DriverManager.getConnection("jdbc:mysql://" + mysql_host + ":3306/" + mysql_database, mysql_login, mysql_password);
          st = conn.createStatement();
          rs= st.executeQuery("SELECT organization FROM tblevent_approval WHERE MAX (keyid))";
          // Get query results.
          while(rs.next()){
            organization = rs.getString("organization");
      finally {
            if(rs != null){
              rs.close();
            if(st != null){
              st.close()
            if(conn != null){
              conn.close();
    %>THE ERROR I AM GETTING
    Syntax error, insert ")" to complete Expression

    This line has the closing bracket inside the closing quote for the statement...
    >       rs= st.executeQuery("SELECT organization FROM tblevent_approval WHERE MAX (keyid))";It should be:
    rs= st.executeQuery("SELECT organization FROM tblevent_approval WHERE MAX (keyid)");A simple typo ;-)
    Hope this helps...

  • Session getting lost between JSPs

    Hi,
    I am working on a application in which a user can upload files using FTP. The files may be of large size, say 50-100 MB and it takes approx 30-60 mins for such uploads. The session timeout for the website is set to 20 mins. The way it works is, from the main browser window there is a link to upload files. This link opens a popup window and through this window the user can upload a file. In this popup window, i have included an iframe which sends a post request to the server every 10 mins to keep the session alive. This is working fine in most of the cases, but sometimes it happens that when the when a call is made to send a post request to the server from the iframe, the session is becoming null & invalid or this happens also after the upload has finished and the "upload successful" page gets loaded. This is a very random behaviour, sometimes it works perfectly fine and sometimes it doesn't. It is not dependent on the time, or the size of the file or the number of times the iframe has submitted the request to the server.
    Any one has any idea why the session is becoming null randomly?

    Hi,
    This should never really happen when you bring up a Web Server or to what so called a loadbalancer in place as ultimately the container which creates the session Object.
    I strongly feel that the Webserver(Apache,Sun App Server or IIS) is not passing on the jessionid cookie value which is actually responsible for this action when we are not using url writing for maintaining. .
    How do test that ??
    try the below code snippet and the rest all is understood on what values you get.
    <%
       //Get the values of respective Properties
       boolean sessionIdFromCookie = request.isRequestedSessionIdFromCookie();
       boolean sessionIdFromUrl = request.isRequestedSessionIdFromURL();
    %>
    From Cookie : <%=sessionIdFromCookie%>
    From URL : <%=sessionIdFromUrl%>Well to sort out problems as these you got to enable passing of jsessionid cookie to the Application Context via Webserver which might call for additional set of configurations from webserver end and AJP part.
    Just as an example let us consider in the case employing IBM http server
    http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/topic/com.ibm.websphere.base.doc/info/aes/ae/xjta_ihs_int.htmlor a neutral way to fix this issue is to adopt usage of a technique called URLREWRITING.
    How do you do that ??
    A quick google search provided me the below results
    http://publib.boulder.ibm.com/infocenter/wchelp/v5r6/index.jsp?topic=/com.ibm.commerce.admin.doc/tasks/tseurlrewrite.htm
    http://www.adventnet.com/products/qengine/help/load_testing/loadscript_creation/recording_bc/url_rewriting.html
    http://java.boot.by/wcd-guide/ch04s04.htmlHope this might help :)
    REGARDS,
    RaHuL

  • Apply SSL in JSP with internal CA signed by Active Directory

    Hi geniuses, who has any idea how to apply SSL into JSP pages.
    I am try add SSL to my authentication JSP pages. My company has exist internal CA signed by Microsoft Server 2003 Active Directory.
    Who's have any idea or tutorial, can you please share to me?

    webster wrote:
    Hi geniuses, who has any idea how to apply SSL into JSP pages.
    I am try add SSL to my authentication JSP pages. My company has exist internal CA signed by Microsoft Server 2003 Active Directory.
    Who's have any idea or tutorial, can you please share to me?This really has nothing to do with JSP or this forum. It's a matter of setting up your Servlet/JSP container properly. Consult the docs for your servlet/jsp container for how to enable SSL.

  • Writing Login.jsp and authenticating a user who have stored in MySql DB

    Hi Friends,
    My project requirement is: Need to write a login page must send the request to servlet is the user and password avail in mysql db, if yes servlet should forward the home page else error message. Tools i need to use is IDE=eclipse, Server = tomcat, database = MySql
    Here is source:
    pls tell me where i m wrong.
    Login.jsp
    <%@ page language="java" %>
    <html>
    <head>
    <title>Login Page</title>
    <script language = "Javascript">
    function Validate(){
    var user=document.frm.user
    var pass=document.frm.pass
    if ((user.value==null)||(user.value=="")){
    alert("Please Enter user name")
    user.focus()
    return false
    if ((pass.value==null)||(pass.value=="")){
    alert("Please Enter password")
    pass.focus()
    return false
    return true
    </script>
    </head>
    <body>
    <h1>Login
    <br>
    </h1>
    <form name="frm" action="/LoginAuthentication" method="Post" onSubmit="return Validate()" >
    Name:
    <input type="text" name="user" value=""/><br>
    Password:<input type="password" name="pass" value=""/><br>
    <br>
    <input type="submit" value="Login" />
    <input type="reset" value="forgot Password" />
    </form>
    </body>
    </html>
    Servlet Code:
    LoginAuthentication.java
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.ServletContext;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.http.HttpSession;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.util.List;
    import java.util.ArrayList;
    public class LoginAuthentication extends HttpServlet{
    private ServletConfig config;
    public void init(ServletConfig config)
    throws ServletException{
    this.config=config;
    //public void init() {
    // Normally you would load the prices from a database.
    //ServletContext ctx = getServletContext();
    // RequestDispatcher dispatcher = ctx.getRequestDispatcher("/HomePage.jsp");
    //dispatcher.forward(req, res);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException,IOException{
    PrintWriter out = response.getWriter();
    String connectionURL = "jdbc:mysql://127.0.0.1/SRAT";
    //String connectionURL = "jdbc:mysql://192.168.10.59/SRAT";
    //127.0.0.1
    //http://localhost:3306/mysql
    Connection connection=null;
    ResultSet rs;
    String userName=new String("");
    String passwrd=new String("");
    response.setContentType("text/html");
    try {
    // Load the database driver
    Class.forName("com.mysql.jdbc.Driver");
    // Get a Connection to the database
    connection = DriverManager.getConnection(connectionURL, "admin", "admin");
    //Add the data into the database
    String sql = "select user,password from login";
    Statement s = connection.createStatement();
    s.executeQuery (sql);
    rs = s.getResultSet();
    while (rs.next ()){
    userName=rs.getString("user");
    passwrd=rs.getString("password");
    rs.close ();
    s.close ();
    }catch(Exception e){
    System.out.println("Exception is ;"+e);
    if(userName.equals(request.getParameter("user"))
    && passwrd.equals(request.getParameter("pass"))){
    out.println("WELCOME "+userName);
    else{
    out.println("Please enter correct username and password");
    out.println("<a href='Login.jsp'><br>Login again</a>");
    Deployment Descriptor for TOMCAT
    web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>
    SRAT</display-name>
    <welcome-file-list>
    <welcome-file>login.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
    <servlet-name>LoginAuthentication</servlet-name>
    <servlet-class>LoginAuthentication</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>LoginAuthentication</servlet-name>
    <url-pattern>/LoginAuthentication</url-pattern>
    </servlet-mapping>
    </web-app>
    PLS HELP ME.
    S. Udaya Chandrika

    I too have used the same code but its giving the following error:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Wrapper cannot find servlet class Validation or a class it depends on
         org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
         org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
         org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
         org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
         org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         java.lang.Thread.run(Unknown Source)
    root cause
    java.lang.ClassNotFoundException: Validation
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
         org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
         org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
         org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
         org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
         org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         java.lang.Thread.run(Unknown Source)
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
    Apache Tomcat/6.0.18
    Please some one help??

  • Session Login and Logout in jsp page

    hi
    i am developing jsp page
    i completed except logout.jsp page
    my login page is in Jsp format and then business Logic in servlet and then get method & set method in bean.java
    i have login and then it sucess page there i have singout button
    if i sign out it should go to login page
    how to do
    how to make session invalidate
    how to get session id
    i have one more doubt i should check session invalidate each jsp page
    regarding session login and logout in jsp
    if anybody knows please give me a piece of code regarding login and logout
    Regards
    Akshatha

    This is part of your filter class now you need login.jsp page
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="Stylesheet" type="text/css" href="/PAS/css/site.css"/>
        <title>Automation System | Login Page</title>
    </head>
    <body>
    <div align="center">
        <h1>Photint Automation System</h1>
    </div>
    <br/><br/><br/>
    <center>
        <table border="1" cellpadding="0" cellspacing="0" width="40%" bgcolor="FFFFFFFF">
            <thead>
                <tr>
                    <th align="left" height="30"> <h3>    Login</h3></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>
                        <div align="center">
                            <form name="LOGIN" action="/PAS/LoginServlet" method="POST">
                                <table border="0">
                                    <tbody>
                                        <tr>
                                            <td height="15"></td>
                                            <td height="15"></td>
                                            <td height="15"></td>
                                            <td height="15"></td>
                                        </tr>
                                        <tr>
                                            <td height="30"></td>
                                            <td align="right" height="30">User Name : </td>
                                            <td align="left"  height="30"><input type="text" name="USERNAME" value="" size="35"  /></td>
                                            <td height="30"></td>
                                        </tr>
                                        <tr>
                                            <td height="30"></td>
                                            <td align="right" height="30">Password : </td>
                                            <td align="left"  height="30"><input type="password" name="PASSWORD" value="" size="35"  /></td>
                                            <td height="30"></td>
                                        </tr>
                                        <tr>
                                            <td height="50"></td>
                                            <td height="50"></td>
                                            <td align="center" height="50"><input type="submit" value="Login" name="Login" />  <input type="reset" value="Reset" name="Reset" /></td>
                                            <td height="50"></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </form>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </center>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/>
    <center>Copyright &copy; 2009 Photint FZ LLC</center>
    <center>Powered by Ali Jamali</center>
    <center>Version : 1.0</center>
    </body>
    </html>And you need loginServlet.java
    package com.ali.util.filter;
    import com.ali.entity.user.UserEntity;
    import com.ali.util.HibernateUtil;
    import java.io.IOException;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    public class LoginServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;
        protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            String username = request.getParameter("USERNAME");
            String password = request.getParameter("PASSWORD");
            if (username == null || username.length() == 0) {
                System.err.println(" Username textfeild is empty ..... !");
                RequestDispatcher dispatcher = request.getRequestDispatcher("Pages/user/LogIn.jsp");
                dispatcher.forward(request, response);
                return;
            if (UserRegistry.isUserLoggedIn(username)) {
                System.out.printf("User [%s] is already logged in. \n", username);
                RequestDispatcher dispatcher = request.getRequestDispatcher("Pages/user/LogIn.jsp");
                dispatcher.forward(request, response);
                return;
            UserEntity user = null;
            try {
                user = (UserEntity) HibernateUtil.load(UserEntity.class, username);
                if (user == null || !user.getPassword().equals(password)) {
                    RequestDispatcher dispatcher = request.getRequestDispatcher("Pages/user/LogIn.jsp");
                    dispatcher.forward(request, response);
                    System.err.println(" Password or username is not valid ..... !");
                    return;
            } catch (Exception e) {
                e.printStackTrace();
                RequestDispatcher dispatcher = request.getRequestDispatcher("Pages/user/LogIn.jsp");
                dispatcher.forward(request, response);
                return;
            HttpSession session = request.getSession();
            System.err.println(request.getRemoteAddr());
            session.setAttribute("username", user.getFirstName());
            session.setAttribute("userType", user.isAdmin());
            UserRegistry.logInUser(username);
            response.sendRedirect("/PAS/index.jsp");
    }finally is you need to just one user can be online at time or need to know how many user & who is online you should at this class also
    package com.ali.util.filter;
    import java.util.ArrayList;
    import java.util.List;
    public class UserRegistry {
        private static final List loggedInUsers = new ArrayList();
        public static void logInUser(String username) {
            loggedInUsers.add(username);
        public static void logoutUser(String username) {
            if (isUserLoggedIn(username)) {
                loggedInUsers.remove(username);
        public static boolean isUserLoggedIn(String username) {
            return loggedInUsers.contains(username);
    }If you have any more Q. or any comment , Most welcome
    Thanks
    Ali Jamali

  • Adding a custom button to Login.jsp

    In AM 7.1 I have a need to add a "Forgot your password?" button to the AM login page. I would like this button to be located just to the right of the existing 'Log In" button and have the same look and feel as the "Log In" button.
    When a user clicks on the button it is going to take them over to our Identity Manager questionLogin.jsp page. Linking the button to the IdM page is easy. What I don't know how to do is modify the Login.jsp page to add another button that has the same look and feel of and is positioned right next to the current "Log In" button. The AM Developer's Guide was of no help. Can anyone help and/or provide a code example that would do what I am looking for?

    Thanks for the reply, Michael. I understand that the Login.jsp needs to be modified and redeployed, but the question is how to create a new button with the same look and feel as the Login button. Currently we have modified the Login.jsp with a "Forgot Password" html link, but it would be prefered to create a button to match what already exists. I understand that this might be outside the scope of this forum, but I was hoping that someone that has done this (specifically the original poster if he found a solution) could share the relevent code.

  • Jdeveloper ADF and Login.jsp

    I would like to change the default login.html to be a login.jsp page so I can format the page better and still use the authen/author used by login.html
    Does some have a sample login.jspx that does the same a login.html.
    Thanks

    Hi Rac Man,
    The following URLs can be useful:
    http://www.radio21g.com/faces/2007/07/24/adf-faces-for-dummies-22-create-your-hello-world-app-continued/
    http://download.oracle.com/docs/cd/E12529_01/webcenter.1013/b31072/tt_security.htm#CHDCIIHE
    http://blogs.oracle.com/shay/entry/for_some_reason_one_common
    http://www.nyoug.org/Presentations/2010/June/Koletzke_Hello_WWW.pdf
    Regards,
    Cris

Maybe you are looking for

  • Regarding sy-uzeit

    My OutPut should be like 12:2900  = hh:mmss i want : column to be inserted between hh and mm in sy-uzeit can any solve this.

  • Adobe Media Encoder - stretching video possible?

    This is a question about CS4 Flash Media Encoder(not Live Encoder) but as I can't find a forum for it, I'm posting here. Is it possible to stretch video? When selecting 'Resize Video' if the software believes the output proportions are different to t

  • Bios A6380VMS.370 or A6380VMS.374 ?

    What is the difference ? I want to upgrade my K7T266 Pro (MS-6380) Thanks Hans

  • Worse performance with Radeon HD 6750m than Intel 3000?

    Lately when i play games (specifically World of Warcraft and Skyrim) and watch movie i get worse FPS and performance on my dedicated GPU than intel 3000. i called apple care and they had me reset the VRAM(?) and something else, i forget. to get rid o

  • Edited Photos Not Showing in Lighroom

    Good day, First the software apps: LIghtroom 5.3 with Camera Raw 8.3 Photoshop cc (Up to date version) Imac with Lion 10.7.5 1. Importing of the Raw files is completed successfully and I see them in the Catalog and Library. 2. I launch Photoshop CC f