Issue at login page using cookies

Hello all
I have some issue with my first cookies-jsp.
Basically i have a homepage and i would like it to prompt a login form in case no cookies are found, and display the userName in case a cookie is found(and stored the name)
In case the user have to log in, the data entered in the form are sent to a "Register" servlet.
I will paste both the jsp and the servlet code, in the bottom i will explain then the problem
The jsp
<body>
        <h1 align="center" style="font-style:italic; color:olive">Welcome</h1>
        <%
        Cookie[] cookies=request.getCookies();
         if(cookies==null || cookies.length==1){
        %>
        <form action="Register" method="post">
        <table cellspacing="5" border="0" align="center">
           <tr>
               <td align="right">Name:</td><td align="right"><input type="text" name="name"></td>
           </tr>
           <tr>
               <td align="right">Email:</td><td align="right"><input type="text" name="email"></td>
           </tr>
           <tr>
               <td align="right">Submit</td><td align="right"><input type="submit" value="submit"></td>
           </tr>
        </table>
        </form>
        <%
          else {
         String cookieName="userName";
         String cookieValue="";
          for(int i=0; i<cookies.length; i++){
              Cookie cookie=cookies;
if(cookieName.equals(cookie.getName())){
cookieValue=cookie.getValue();
%>
<h3 align="center" style="font-style: italic; color:#6666FF">Welcome back <%=cookieValue%></h3>
<%
%>
</body>
The servlet (the relevant part, the doPost() method):protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//get the user details
String name=request.getParameter("name");
String email=request.getParameter("email");
//create the cookie and add to response
Cookie userName=new Cookie("userName",name);
userName.setPath("/");
userName.setMaxAge(60*60*24);
response.addCookie(userName);
//prepare for forwarding
String url="/home.jsp";
RequestDispatcher dispatcher=this.getServletContext().getRequestDispatcher(url);
dispatcher.forward(request,response);
The problem is that when i enter the userdetails the first time in the form (because no cookies was found), the login page with the form  is redisplayed, and if i click on refresh or reclick on th submit button then the message with the name is displayed.
I dont understand this behaviour, since the amount of cookies after the first login is made will be "2", the homepage with the username should be redisplayed and not the one with the login form.
Any advice?
p.s:
the  if(cookies==null || cookies.length==1){ its to prevent that the jsp will consider the JSESSIONID as "logged in" cookie
Edited by: enrico on Jan 23, 2011 10:36 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Turn off the cache in your browser or set an expire header in your servlet.
Also, you might want to consider using the servlet session instead of manipulating the cookie directly.

Similar Messages

  • Issue with login page

    Hi,
    Can anyone help me with the following issue: When I try logging into the login page using the URL_*(http://hostname.domainname)*_ the page is re-directed to the same URL but with https:_ in front of the URL but the login page is not displayed/shown.
    But when i remove the 's' from https:_ and press enter i get the login page.Once i Login with the credentials also it is again re-directed to the https:hostname.domainame_.
    Again only if i remove the 's' from (https:hostname.domainame) and press Enter do i get the responsibility page.This is happening each and every time when i click on responsibility its re-directed to https: link and i need to remove the 's' from https and press Enter to get the responsibility displayed.
    Can anyone help me out with this issue.
    Apps version :11.5.10.2

    Do you have SSL implemented? If not, please review the application context file for any referenced to https and change it to http then run AutoConfig and bounce the services.
    Also, check if any of the profile options is set to https and change it to http -- How to Search all of the Profile Options for a Specific Value [ID 282382.1]
    Thanks,
    Hussein

  • How to create login page using OAF

    Hi,
    I am using Jdeveloper 11.1.1.6.0
    Plese give me Sample Code creating the log in page .
    Thanks
    Ram

    Hi,
    here i am using the webcenter application using the adf faces need secured login page using the OAM.
    Thanks
    Ram

  • Create login page using jsp, servlet  & Oracle

    hi,
    i need the sample application for creating login page using jsp, servlet & Oracle,can you please post one sample application.
    thanks
    sona

    See
    http://www.oracle.com/technology/products/jdev/collateral/papers/10g/adfstrutsj2eesec.pdf
    Frank

  • How do you create a login page using dashcode for the iPhone's mobile safari that will transfer you to the next page?

         Hey I have created a login page in Dashcode for a mobile safari app (aka iphone web app) and I am having trouble since I can not find any useful info about multiple pages. I don't want to use a stack layout view because it is only a login page and I need to check with a database to make sure the user's login info is correct. Right now I have it set up so that it loads another iphone web app project once it validates the info.
         The only problem with this is I am having a good bit of trouble trying to pass values from my php code to javascript or html. For some reason calling the javascript inside the php code makes the actual code inside the app not be called and same with the echo statment for the html.
    So I would like to be able to create the app in this way:
    Login page > PHP > MS SQL > PHP > UNKNOWN (if I can't get the javascript or html to output both) > Secure info on the next page
         I believe It would be a lot easier if I had the option for a multiple page but instead I am having to load up an entirely new dashcode project. If anyone knows a better way please let me know. Or if anyone knows a link to good information on passing values from php to javascript, because I couldn't get any of the code I tried to work, I would really appreciate it.

    Addendum to previous reply:
    OK.  This is weird--but I should be used to that, and just grateful that it seems to work (for now).
    What I had done is FTPd some image files to my site using Filezilla, but when I had tried to access them, I was unsuccessful.  I am almost sure that I used the same url (and variations of it) as you suggested, namely,  http://mysite.verizon.net/username/filename , and it either did not work, or gave me the "Page under construction", or, in some cases asked me for my username and password.
    But, when I did it this time, it worked.  So I probably had something off, but I can now do what I want.
    By the way, if you'll permit another question, while on the site-builder site, it said that there was a "Web Photo Manager", and said that "To download the Web Photo Manager: Open the Site Builder application and go to the All My Sites page. Click on the Web Photo Manager link (listed under Advanced Building Tools )."  I can't find it--would you happen to know where it is?
    In any case, thanks a lot for all your help--it solved my problem. 

  • How to make a simple login page using java creator studio and mysql

    Hi,
    I hav got java creator studio n my sql.Can u give me the code for login page authentication and navigation

    This is a forum about Java language questions, not about how to use a developers tool. I would say to go to the site where you got java creator studio from, and look for a forum there.

  • Create a login page using when button is pressed trigger

    I need to write a code that allows users to enter their name and password and there organisation type. If the organisation type entered is staff they are takeing to the appropriate block if it is courts they are taken to another block. This is what I am stuck on. If anyone could help I would be extremley grateful.
    declare
    staff_id varchar2(4);
    user_password varchar2(8);
    org varchar2(10);
    alert_button number;
    begin
    select employee_no,n_password,organisation_type
    into staff_id, user_password,org
    from organisation
    where :login.text_item_user_name=organisation.employee_no and :login.text_item_type= organisation.organisation_type;
    if(staff_id =:login.text_item_user_name AND user_password =:login.text_item_password)
    then go_block('Driving_Test');
    else
    else
    alert_button := show_alert ('Alert_Incorrect_Login');
    if alert_button= alert_button1 then
    clear_block;
    end if;
    end if;
    end if;
    end;

    OK. So does the code work? Are you getting a compilation error? Please be more descriptive. Also, it is helpful if you use the tags round your code so it will be formatted and easier to read. :)  Check out the <a href="http://forums.oracle.com/forums/help.jspa">FAQ </a>link for a list of other useful formatting tags.
    Craig...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • EBS 12.1.3 Login page issue or page cannot be displayed

    When I try the login page using http://host.domain/OA_HTML/AppsLocalLogin.jsp or http://host.domain/OA_HTML/AppsLogin, then the browser is displaying page can not be displayed.
    When I try to run AOL/J Diagnostic Tests, using http://host.domain/OA_HTML/jsp/fnd/aoljtest.jsp, then I did not find any issues.
    When I try to run AOL/J Setup Test, under Verify DBC Settings, there is a WARNING: Security in database set to "SECURE". If the DBC file contains the wrong APPL_SERVER_ID, then no JDBC connections will be possible via AOL/J.
    But under Verify Guest Settings, there is an ERROR saying :Failed to validate GUEST user in Profiles.
    Please help what is causing the login screen not able to show up.
    Thanks.
    Edited by: user5618898 on Sep 29, 2012 7:43 PM

    Never mind, it was a port conflict. I tried to change the http port # to default port #80 to a cloned copy. By flipping it to a different port and then run the autoconfig, resolved the issue.

  • How to: create a Login page with data tags

    hi, how could i create a jsp login page using the data tags.. and how to associate it with the other jsp pages that should be displayed in case of the correct insertion of the password .

    http://technet.oracle.com:89/ubb/Forum2/HTML/006025.html

  • Access problem in the login page

    Hi ,
      I downloaded the "SAP NetWeaver 2004s Java Trial Version" from SDN and installed it . During the installation I kept all the passwords as "abcd1234" following the instructions of the installation guide . After the installation , the guide tells me to login to the server(ie portal login page) using
    user = admin
    pwd = admin
    Now when I try to login , it says authentication failed and after a while of trying different passwords the message that appears now is "account locked" . What do I do to login into the SAP portal. Coulld someone pls help here .
    Regards
    Deepak Singh

    Hi Deepak
    Have you installed portal?If yes try loggin into it with
    User :administrator
    password:abcd1234
    Pls award points:
    <i></i>
    Message was edited by:
            Rajat Anand
    Message was edited by:
            Rajat Anand

  • Login form using JSC n MySql

    please send me full code for a simple login page using my jsc n mysql

    here i hav got code for a simple login form usin
    JAVA and MySQl
    public String button1_action() {
    String Username = (String) this.textField1.getValue();
    String pwd = (String) this.passwordField1.getValue();
    boolean isValidUser=false;
    com.sun.sql.rowset.CachedRowSetXImpl loginRowSet=new com.sun.sql.rowset.CachedRowSetXImpl();
    try {
    loginRowSet.setDataSourceName("java:comp/env/jdbc/sms");
    loginRowSet.setCommand("SELECT * FROM login");
    loginRowSet.setTableName("login");
    loginRowSet.execute();
    loginRowSet.beforeFirst();
    while(loginRowSet.next()){
    String Username1 = loginRowSet.getString("name");
    String Password1 = loginRowSet.getString("password");
    if(Username.equals(Username1) && pwd.equals(Password1)){
    return "case1";
    if (!isValidUser){
    staticText1.setValue( " logon failed");
    catch (Exception e) {
    error("Login Failed : " + e.getMessage());
    throw new FacesException(e);
    } finally {
    loginRowSet.close();
    return null;
    Make some changes in session bean also
    protected ApplicationBean1 getApplicationBean1() {
    return (ApplicationBean1)getBean("ApplicationBean1");
    plz add this also
    public boolean do_rand() {
    boolean do_rand = true;
    try{
    loginRowSet.setCommand("SELECT * FROM login ");
    }catch(SQLException ex) {
    if(ex != null ){
    ex.printStackTrace();
    errorRand = "error do random";
    do_rand = false;
    return do_rand;
    } catch(Exception e) {
    e.printStackTrace();
    return false;
    return true;
    }

  • Login screens using mod_plsql

    Hi,
    is it possible to develop a login page using mod_plsql ?
    Thanks
    James

    Hi Alex,
    The EPG can use the XDB WebDav.
    - Make your application user XDBADMIN (db role)
    - You can access the WebDav by using IE: File -> Open -> enter url of your EPG url + port (no DAD) and check the webfolder box.
    - You might get asked a username/password: use your db application schema/password
    - You should see at least two folders: public and sys
    - execute the following code with the XDBADMIN granted user:
    DECLARE
      v_xml_dir VARCHAR2(30) := '/yourdir';
    BEGIN
      IF dbms_xdb.CreateFolder(v_xml_dir) THEN
        dbms_xdb.setAcl(v_xml_dir,'/sys/acls/bootstrap_acl.xml');
        dbms_xdb.setAcl(v_xml_dir,'/sys/acls/all_owner_acl.xml');
        dbms_xdb.setAcl(v_xml_dir,'/sys/acls/ro_all_acl.xml');
        dbms_output.put_line('Success');
      ELSE
        dbms_output.put_line('FAILED!'); 
      END IF;
      COMMIT;
    END;
    /- now you should see your newly created folder in the webdav
    - just cut'n'paste your images into this folder
    -you can access these images like: http://EPGserver:port/yourdir/image.gif
    Hope this helps,
    Christian

  • Secure login page won't load

    I have a problem that is driving me crazy involving my MacBook's (older Core Duo) wireless connectivity. I'm trying to connect to a corporate server (https://loginpage.aspx) using my home wireless network, Netgear router (WGT624). It starts as a browser based connection for login, successful login launches the Citrix client, but I can't even get the login page to load, and here's the crazy part (to me).
    If I turn off the Airport card and connect an ethernet cable I can load the login page. If I hop onto another open wireless network the login page loads. On my iMac (older Core Duo) I can load the login page using ethernet cable or Airport card. Both computers have the same updates and network settings. I have tried both Safari and Firefox, even IE, in multiple users. I reset the router. I reinstalled the Citrix client, not that the process gets that far.
    So I'm left with two thoughts, the Airport cards MAC address has been blocked by the corporate firewall (even possible??), or there's some file deep in a (.)hidden folder that is causing a problem.
    Hopefully someone reading this can give me another approach, short of trying a complete reinstall.

    Updated router firmware

  • Session/cookie in an app without login page

    Hi,
    I know there are several threads about setting a cookie, checking session etc. But none seem to address my issue. Here's my problem:
    - I don't have a login page in my apex app. My user logs in from an external program and his userid is captured in the HTTP header variable 'remote_user'.
    - I added some PL/SQL code in the 'page sentry function' to check if this user is in the database(basically check if he is in one of the tables) and if he is not, show him the page without the create/edit/delete buttons. If he is in our database, show the same pages with all types of buttons.
    - Putting this code in page sentry function seems to work, but I am unable to logout since there is no cookie set! If I try to set a cookie in the page sentry function, it is breaking at the redirect line. Also, I don't think page sentry is the right place to set a cookie since it executes at every page.
    - Putting the above code in any other block (session verify function, pre-authentication, authentication, post-authentication etc) does not even execute. I put a simple 'insert' query to see if it executes, but it does not!
    Given this, what is the best way and place to set/check cookie in my app? I tried to enhance Scott's session timeout utility, but my app does not have a login function as I explained above, so I am unable to do that. Any help is appreciated!
    Thanks.
    Shuba

    I tried to do that. If you read my very first post in this thread, specifically "If I try to set a cookie in the page sentry function, it is breaking at the redirect line. Also, I don't think page sentry is the right place to set a cookie since it executes at every page.", I tried to set a cookie but it is throwing an error at the page.
    I think all these complication is because I dont have a login page and I am using a HTTP header variable to validate the user. Given that, where should I set the cookie?
    I also tried to do this:
    - create an appliaction item called 'testuser'
    - create an application computation to run 'before header' which sets the value of this to my HTTP header variable.
    - When I retrieve the app item 'testuser' from a page, it is getting the correct value. But when I use this in the authentication scheme, it is returning null. Any idea why??
    I know I am throwing a lot of questions. That is because I am trying a lot of approaches and each of them is posing a new set of challenges. I am actually looking for alternative ways to do what I am looking to do.
    Thanks.
    Shuba

  • 11i Login Page is showing 'Error on Page' while using IE 7

    Hi DBAs,
    I am using Oracle 11.5.10.2 with DB 10.2.0.4 (Single Instance). The EBS is on RUP6 and using JDK 1.6.0_12.
    I was using Firefox and not getting any issue. I used first time IE-7 (7.0.5x) to access the application. I noticed that Pressing the 'Login' button on Login Page , it was saying in the left bottom of the IE says 'Error on page' and was not navigate to any page or did not perform any action.
    I verified all the services and everything was OK. While using Firefox , I was able to navigate the application w/o any issue.
    Using IE 7 , I am able to access
    http://host.domain:8000/OA_HTML/fndvald.jsp?username=sysadmin&;password=sysadmin
    Most of the stuff seems to be working fine while logging in using above URL but the 'GO' buttons are throwing same error in IE 'Error on page'. Rest of the Bottons like 'Edit Navigator' , 'Edit Favorites' are working fine but when on any Page I press the 'Go' button then IE showing Error. It seems to me that when a button need to navigate to next page then IE saying 'Error on page' but when a button have to lunch a new page it is working fine.
    All the responsibilities and links are working fine. Application Navigation using Firefox is working absolutely fine.
    Seeking your advise and suggestions to resolve the issue.
    Thanks
    -Samar-

    Hi Samar,
    You can clear the cache as follows (login as applmgr user, and source the application env file):
    $ cd $COMMON_TOP/_pages
    $ rm -R *
    ML Note: 285218.1 is not helpful as I am on later version of EBS (11.5.10.2 with RUP6 and Developer6i Patchset 19). At Client side I am using Windows XP SP3 with IE 7.0.5.x with JInit 1.3.21 and JRE 1.6.0.12.Did you review the steps under "Recommended MSIE Browser Settings" section?
    Can you reproduce the issue with JInitiator? If yes, any errors in the JInitiator console window? Enable debug (you may also enable trace for Sun JRE) and see if any errors are reported there.
    Note: 549423.1 - How to enable tracing and logging for Sun JRE (Native Plug-in)
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=549423.1
    Regards,
    Hussein

Maybe you are looking for

  • Screen flicker with temporary lockups

    System: 1.4 G Athlon Asus A7M266 motherboard MSI 8831 Geforce2 Pro Video card Sound Blaster Live! I-Will SATA RAID controller card 2 x 120 Gig Maxtor Diamond Max Plus HD ethernet card I recently upgraded to the 2 maxtor hard drives.  And since my mot

  • Main Asset master problem

    Hi Every body, when i am posting the F-90 Asset purchased , This error will be coming <b>No depreciation areas have been defined for asset 1-0</b> when i am creating the main asset master After click the Depreciation area it's not available any infor

  • Know the price from cost center and actyviti type

    Hi expert, I Know the cost center and the actyvity type. I have to know the price: I can use the transaction KSBT but I need to know some BAPI or tables without using KSBT . Any idea ?? tks a lot, bye.

  • VirtualBox does not start shows weird error message

    Hi, What could be the trouble? $ sudo VirtualBox VirtualBox: supR3HardenedMainGetTrustedMain: dlopen("/usr/lib/virtualbox/VirtualBox.so",) failed: /usr/lib/virtualbox/VirtualBox.so: undefined symbol: _ZN9QListData11detach_growEPii Thanks --Siju

  • SharePoint Labels and Document Templates

    Hi, i added a SharePoint Templates to a library to update documents with the document version numbers: Did it like this if you need more info: http://daniecsp.blogspot.com/2014/02/add-sharepoint-version-number-to-word.html That was working updating t