Creating Logout button and invalidating session

Hello All:
I'm new to java and I'm trying to figure out how to log a user out of a web servlet. Basically I just have a link that returns the user to the first servlet (my login servlet) called log out. I am wondering if when I click on that link (or do I need to make it a button) that I can tell the servlet to invalidate the session I have created, therefore allowing a new user to login from the login servlet.
I honestly have no idea how to go about this. The following is my code from another servlet in my group:
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
* @author Owner
* @version
public class Item1ServletHW2 extends HttpServlet {
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
HttpSession session = request.getSession(true);
String getuser = (String)session.getAttribute("getuser");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet Item1ServletHW2</title>");
out.println("</head>");
out.println("<body>");
out.println("<form action=>");
out.println("<table border=1 align=center width=65%>");
out.println("<tr><td align=center bgcolor=blue colspan=3><font color=white size=3>Welcome to the Music CDs Page </font><font color=red size=3><b>"+getuser+"</b></font></td></tr>");
out.println("<tr><td width=60% bgcolor=green align=center><font size=2 color=white><b>Item</font></td>");
out.println("<td width=10% bgcolor=green align=center><font color=white size=2><b>Unit Price</b></font></td>");
out.println("<td width=40% bgcolor=green align=center></td></tr>");
out.println("<td bgcolor=green align=left><img src=coldplay.jpg><font color=white size=2>ColdPlay X&Y</font></td>");
out.println("<td bgcolor=green align=center><font color=white size=2>$19.99</font></td>");
out.println("<td bgcolor=green align=center><input type=button name=addcart2 value=Add to Cart></td>");
out.println("</tr>");
out.println("<td bgcolor=green align=left><img src=oakenfold.jpg><font color=white size=2>Oakenfold - The Club</font></td>");
out.println("<td bgcolor=green align=center><font color=white size=2>$17.99</font></td>");
out.println("<td bgcolor=green align=center><input type=button name=addcart1 value=Add to Cart></td>");
out.println("</tr><tr><td colspan=3 align=center><font size=2 color=white><a href=CatServletHW2>Main Catalog</a> | <a href=ShopCartServletHW2>View Cart</a> | <a href=RegLoginServletHW2>Log Out</a></font></td></tr>");
out.println("</body>");
out.println("</html>");
out.close();
The Log Out link is the one I want to check when clicked, and if so, invalidate my session before the user is redirected to the RegLogin Servlet. Any help would be greatly appreciated. Thanks so much :).

I understand how to invalidate the session, but with this example:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class logout extends HttpServlet
          public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
               res.setContentType("text/html");
               PrintWriter pw = res.getWriter();
               HttpSession ses =req.getSession();      
               ses.removeValue("desi");
               ses.removeValue("Login");
               ses.removeValue("password");                    
               res.sendRedirect("http://localhost:8080/examples/servlets/login.html");                    
How can I get this to process when clicking a link called "Log Out", or is there a way to create an onClick button that invalidates the session when clicked. Maybe something like this:
onClick="session.invalidate();response.sendRedirect("somewhere");>
Thanks for the helps, but I'm still a bit confused :).

Similar Messages

  • Creating radio button and make it ennable

    Hello All ,
    Please help me out in creating radio button and make it ennable in web dynpro in java application .
    If Possible please send the sample code as well.
    Thanks
    jyothi.

    Hi Venkat,
    The default value needs to be set manually as John has suggested. To be more precise, if the context node is "RadioButtonValues" and the context attribute is 'RadioBtnVal', then in wdDoInit() method, include the following:
    wdContext.currentRadioButtonValuesElement.setRadioBtnVal("Male");
    Regards,
    Pavithra

  • Hide or disable logout button and welcome text

    How to hide or disable logout button and welcome text in page?

    BODY:
    <div id="header">
      <div id="logo"><a href="#HOME_LINK#">#LOGO##REGION_POSITION_06#</a></div>
      #REGION_POSITION_07#
      <div id="navbar">
        <div class="app-user">#WELCOME_USER#</div>
        #NAVIGATION_BAR#
        #REGION_POSITION_08#
      </div>
    </div>
    <div id="tabs">
      <div class="frame">
        <div class="bg">
          <div class="tab-holder">
          </div>
        </div>
      </div>
    </div>
    <div id="topbar">#REGION_POSITION_01##REGION_POSITION_04#</div>
    <div id="messages">#SUCCESS_MESSAGE##NOTIFICATION_MESSAGE##GLOBAL_NOTIFICATION#</div>
    <div id="body">
      <div id="three-col">
        <div id="left-sidebar">#REGION_POSITION_02#</div>
        <div id="two-col-tbl">
          <table class="tbl-body" cellspacing="0" cellpadding="0" border="0" summary="">
            <tbody>
              <tr>
                <td class="tbl-main" width="100%">#BOX_BODY#</td>
                <td class="tbl-sidebar">#REGION_POSITION_03#</td>    
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>

  • Logout button and Page submission problem

    {color:#000080}Hi All,
    We have logout buttons on every page of our application. The problem is that if the user clicks on any part of the page, even on the group-panel, the logout button gets the focus and a hit on the enter key causes the user to log-out.
    I want that the logout button, should not get any focus unless and until it is clicked by the user to logout.
    Any help will be highly appreciated.
    Thanks,
    Sheen
    {color}

    Here is what I do.
    Create a page fragment that contains the logout link/button.
    I use this in a menu panel page fragment or a header panel page fragment.
    That way, you can just add the page fragment and don't have to duplicate code on every page.
    The only thing you have to do is make sure the navigation is set up properly.
    For example. I create a menu page fragment with buttons that go to each page of my application.
    The menu page fragment has all the logic to return the proper navigation string.
    The page fragment is incorporated into the page.
    You have to set up the navigation rules for each page, but do not have to include the button logic since it is included with the page fragment.
    This also isolates you from the problem where a return activates the logout button.
    As an aside, you might want to trap the return keypress and direct it where you want or toss it.

  • Creating Add button and array

    Hello,
         I am sure this has been brought up before but I am still not clear on the procedure as I am still new to this. In my coldfusion application I need to create a Button with 'ADD' function.
    When the button is clicked a new text field with a checkbox is created, however, these will need to have a unique names because they will be submitted into MySQL Database table. Of course, unless a dynamic variable can be created and submitted.
    I think I need to get an array function in javascript/ajax?
    I appreciate any help.

    Yes thank you.
    I  know some about the element function in java, but what I worry about is when sending the data into the MySQL and it may be multiple inputs anywhere from 1-500, so I need to create multiple elements. As far as I understand it.
    When I ran my test, the database only inpuy the original text but nothing from the elements I've created using javascript.
    Here is my script:
    <td colspan="3"> Item 1 <cfinput type="checkbox" name="Item" value=" Item1"> </td></tr>
    <tr>    
    <td align="left">Text: </td>
    <td>     
    <!--- textfield --->   
    <cfinput  type="text" name="Text1" size="30">    
    </td> </tr>
    <tr>
    <td align="left">Comments:</td> <td>      <!--- textarea --->
    <textarea name="Comments" cols="30" rows="5"></textarea> <br>
    <input type='button'  value='MORE' onclick='addbox()'>
    </td>
    <td>
    <div id = "Input1"></div>
    <div id = "Input2"></div>
    <div id = "Input3"></div>
    <div id = "Input4"></div>
    <scripttype = "javascript">
    var i = 1;
    function addbox() {
    if (i <= 4) {  // max number of inputs
    document.getElementById('Input'+[i]).innerHTML =  "<input type='text' name='text1' value='Enter Text Here' size = '15' /><br> Comments:<textarea name='Comments' cols='30' rows='5'></textarea> <input type='button' value='MORE' onclick='addbox()'>";
    i++;}else {
    alert ("No more inputs are possible")
    </script>
    </td>
    Of course, once the this step is complete, the form is being submitted as a whole
    The following page is contains SQL Commands of:
    <cfquery datasource="test">
    INSERT INTO ProcessTBL (Item, text1, comments)
    VALUES ('#Trim(Form.Item)#', '#Trim(form.Text1)#', '#Trim(form.comments)#')
    </cfquery>
    All functions as it should, but the problem I am running into is that only CFINPUT text is being inserted into the database and none of the javascript inputs, unless, of course I am missing a variable. Another concern I have is that, once again, the input may be up to 500 variables.
    Once again, I appreciate your help.

  • Creating radio buttons and text box in the screen

    Hi Guys,
    Need help asap. I am writing a report and I have to create text box for user to input GL account numbers for two types of customer. I have to make these fields required and take the data back from the screen and write it in a file. The second thing that I have to do is to make radio buttons for the user to select whether he wants the file written on the application server or the presentation server. and process the report accordingly. Now can somebody please given some code and tell me how I should do this. Both the things have to be done for the same report. Please help.
    Thanks,
    Minal

    Hi,
    TABLES: likp,
            lips.
    TYPES: Begin of ty_likp,
           vbeln like likp-vbeln,
         end of ty_likp.
    TYPES: Begin of ty_lips,
           vbeln like lips-vbeln,
           posnr like lips-posnr,
         end of ty_lips.
    DATA:  i_likp TYPE STANDARD TABLE OF ty_likp,
           i_lips TYPE STANDARD TABLE OF ty_lips,
           w_lips TYPE ty_lips,
           w_likp TYPE ty_likp.
    SELECTION-SCREEN BEGIN OF BLOCK b_0 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:  s_delno FOR likp-vbeln,
                     s_type  FOR likp-lfart,
                     s_ship  FOR likp-vstel,
                     s_date  FOR likp-erdat.
    SELECTION-SCREEN END OF BLOCK b_0.
    SELECT vbeln
             FROM likp INTO TABLE i_likp
             WHERE vbeln IN s_delno
             AND   lfart IN s_type
             AND   vstel IN s_ship
             AND   erdat IN s_date.
      IF sy-subrc <> 0.
        MESSAGE i000 WITH text-002.
        " No valid deliveries for the selection parameters entered.
        STOP.
      ENDIF.
      IF NOT i_likp[] IS INITIAL.
        SELECT vbeln
               posnr
               FROM lips INTO TABLE i_lips
               FOR ALL ENTRIES IN i_likp
               WHERE vbeln = i_likp-vbeln.
      ENDIF.
    format color 1 on intensified on.
      WRITE: /01(46) 'Following are the Hanging Deliveries/Invoices:'.
    format color off intensified off.
    skip.
    format color 1 on.
      WRITE:  SY-ULINE(27).
      WRITE: /1       SY-VLINE,
              3(12)    'Document No.',
              16      SY-VLINE,
              17(8)  'Item No.',
              27      SY-VLINE.
    write:/1 sy-ULINE(27).
    format color off.
      sort i_lips by vbeln posnr.
      LOOP AT i_lips INTO w_lips.
          Read table i_likp into w_likp with key
                            vbeln = w_lips-vbeln
                            posnn = w_lips-posnr.
          if sy-subrc <> 0.
          format color 2 on.
             WRITE: /1   sy-vline,
                    3(12)  w_lips-vbeln,
                    16  sy-vline,
                    17(8)  w_lips-posnr,
                    27  sy-vline.
            write:/1 sy-uline(27).
            format color off.
            clear w_lips.
          endif.
          ENDLOOP.
    Try this one with ur own example.
    Thanks & Regards,
    Judith.

  • Create a Button and run ABAP

    Hi,
    I´m trying to put one button (or link) in my Web Template and call an ABAP code.
    Shailesh comments about service help and I search many discussions about this, but I dont know how can I do this.
    I created a two class:
    ZBUENO (Super Class CL_RSR_WWW_MODIFY_TABLE)
    Z_SERVICE (Super Class CL_RSR_WWW_HELP_WINDOW)
    Putted on my Web Template, break-points was working, but I need to execute one ABAP when the user clique on button, otherwise, every time my ABAP will be executed.
    Tks for any help,
    Bueno

    Dear Frank, please, can you take a look on this code:
    The first part we create a link to try cmd SUBMIT and in my class Z_SERVICE I putted a break-point on PROCESS_CMD method. Is this correct?
    <BODY>
    <P> </P>
    <A href="<SAP_BW_URL cmd="SUBMIT" help_service="Z_SERVICE" item="TABLE_1">">Generate File</A>
    <P><object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="GET_ITEM"/>
             <param name="NAME" value="TABLE_1"/>
             <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_GRID"/>
             <param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>
             <param name="WIDTH" value="651"/>
             <param name="HELP_SERVICE_CLASS" value="Z_SERVICE"/>
             ITEM:            TABLE_1
    </object></P>
    </BODY>
    Very thank you !!

  • ZLM00: How to create the logout-button?

    LS.,
    I am creating my own LM00 screens which work fine. There is one button hat I still have to add: LOGOUT.
    Of course I can create the button and give it a functioncode, but what do I have to let it do to make the user logout?
    I tried functions like:
    EXIT, LEAVE TO SCREEN 0, LEAVE PROGRAM, LEAVE, RETURN, STOP, CALL TRANSACTION '/NEX'.
    Also I tried to debug the original LM00 transaction, but it is not debuggable using /h /hs or /he.
    I have also searched for function modules that log the user out, but did not find any.
    Anybody any idea how to create the logout-button?
    Best regards,
    Tim van Steenbergen.

    Got it.
    Functionmodule SAPGUI_SET_FUNCTIONCODE does some part, but only works for a dialogsession. When trying this on a scanner, it did not do anything because this interface does not have a transaction box to enter the functioncode in.
    The trick that worked was call 'SYS_LOGOFF'.

  • Smartview 11.1.2.1 invalid session on Hyperion Distributed enviroment

    Good day
    We installed HFM Hyperion 11.1.12.1 in a distributed enviroment with 2 web servers , 2 app servers and 2 Reporting servers
    Everything is working well ,but we encountered the problem on smartview 11.1.2.1 if we use web1 we get the this error in smartview if we create a private connection
    "Invalid session.One Possiblity is that the session has timed out .Login again
    If we use web2 and create a private connection it works fine
    Both servers are identical
    Windows 2008 R2 sp1 Hyperion 11.1.2.1
    any ideas?
    Regards
    Chris

    Do you use OHS?

  • How do you enable 'Create Content' button on 'Add Content' page?

    How do you enable ‘Create Content’ button on ‘Add Content’ page?
    There is new functionality to a ‘Layout’ type personalization page like ‘Sales Dashboard’.
    Bug 4503123 INCONSISTENT WAY OF ADDING USER-DEFINED REGIONS ON WYSIWYG PAGE:
    There’s no way to add custom content to a configurable page.
    Add a “Create Content” button and let the user create a piece of content that extends to a region he creates.
    It says: Fixed->11.5.10.3CU
    In Oracle® Application Framework Personalization Guide Release 11i Part No. B25439-02 it says:
    p 4-5
    If you personalize a non-configurable page (a page that does not have the necessary metadata to personalize its layout) or when you run your application in Accessibility mode (profile option Self Service Accessibility Features (ICX_ACCESSIBILITY_FEATURES) is set to Standard Accessibility), you will not see the Page Layout Personalization page, as shown below. Instead, you will see the Page Hierarchy Personalization page, page 4-12, where you can perform the same personalization functions, using a descriptive tabular user interface.
    It tried this and can’t get it to display.
    Has anyone run accross this before?

    user587952,
    Can you describe your issue in detail forgetting those references for the time being. What exactly are you trying to do?
    Check this from the dev guide:
    In order to be able to take full advantage of page layout personalization capabilities, it is important when you create your configurable page, to use flexibleLayout and flexibleContent regions at all levels when you create the page hierarchy structure under your page layout region. In Oracle Applications, this is required, as it is the coding standard.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How can i create a button? t

    i'm new in using flash, how can i create a button and link it in other scene? thanks in advance

    Please re-post the question to the Flash forum at http://forums.adobe.com/community/flash/flash_general.
    Steve

  • Dynamic buttons and itemlisteners????

    I'm trying to do something that might not be possible. I would like to create some buttons and actions for those buttons on the fly. For example:
    1) read some files from a directory (these file store settings)
    2) Create buttons using the filenames as the button labels
    3) Create associated actionPerformed section related to those buttons
    I want to do this because the amount of files and there names could change all the time. Basically I want to create a button for each file, and essentially launch an application using the settings file as part of a process.
    So far I've read a filename into a string. The first problem, how do I use that filename as the name of a button?
    JButton "string value" = new JButton();
    Then, subsequently, how to you set up the action? See code snipet below.
    Hope that made some sense. Can anything like this be done?
    Thanks,
    James
    //this loads the buttons
    for (int i=0; i < main.size(); i++)
         Vector temp = new Vector();
         temp = (Vector)main.elementAt(i);
         JButton buttonName = new JButton((String)temp.elementAt(0));
         buttonName.addActionListener(this);
         northFlow.add(buttonName);
    //this is in the actionPerformed section
    for (int i=0; i < main.size(); i++)
         Vector temp = new Vector();
         temp = (Vector)main.elementAt(i);
         if (source == (String)temp.elementAt(0))
                loadProgram((String)temp.elementAt(0));

    There is a way to give a button a variable name equal to the file name but it involves extremely advanced Java programming involving creating dynamic class instances. I would strongly discourage this approach because debugging it when it doesn't work, can be a nightmare.
    There is a much easier way to do this however. Create an array of JButtons. Call it, oh say, "MyButtons". Then at the appropriate places, you can do:
    JButton[] MyButtons;
    MyButtons = new JButton[ main.size ];
    for ( int i = 0; i < main.size(); i++ ) {
       Vector temp = new Vector();
       temp = (Vector)main.elementAt(i);
       MyButtons[i] = new JButton( (String)temp.elementAt(0) );
       MyButtons.addAction...
    Incidently, you may also want to re-think your data structure. From what I understand, you have an array where each element is a vector (another array of zero or more elements). This results in code that is difficult to read and write. Consider making your own objects instead of using vectors, then you could write something like...
    for ( int i = 0; i < main.size(); i++ ) {
       if ( source == main.getProgramName() ) {
    loadProgram( main[i].getProgramName() );
    The nice thing about this approach is that you can mix and match objects within the array, or add elements to each object in any particular order and it won't break the rest of your code.
    P.S., use the square brackets to indicate arrays. For some reason, this board is converting them into angle brackets.

  • Buttons and text items on oracle forms 6i

    can i create dynamic buttons and text fields on oracle forms 6i.
    i mean when i insert record in database then automatically creat a button on form.
    Regards
    Munawer hussain

    Hi,
    One physical button is enough for a series of "functional buttons" per amount of simultanious visisble buttons. You can change the button prompt at run-time depending on a certain condition. That same condition can also be used when executing the when-button-pressed (wbp) trigger.
    Example:
    suppose you have 2 functions that you want to create buttons for: enter query and execute query. Only 1 button is visible at one time. In design time you create 1 button. In run-time, depending on :system.mode you set the button prompt to "enter query"or "execute query" and in the wbp trigger you write
    begin
    if :system.mode = 'QUERY'
    then
    execute_query;
    else
    enter_query;
    end if;
    end;
    Kind regards
    .

  • Bidder should be able to get create response button before payment of Tender fee

    Hello Friends
    I would like to discuss and find solution for below scenario :-
    In case of Open Tender, Tender Fee is required to pay either Online/Offline before submission of bid because it is marked required in customization “Define Tendering Option”.  Subsequently When Vendor Clicks on Register button and system check whether Tender Fee is paid by the vendor or not. If tender fee is paid then system show “create Response button” but tender fee is not paid by the vender then system doesn’t show “Create Response button”.
    Business requirement is to Appear Create Response button before payment of Tender fee but when we marked “Tender Fee” as optional in customization “Define Tendering Option” than Create Response button is appear before payment of tender fee but other side from purchaser portal while payment offline payment, Tender Fee is not showing in drop down of Related link. I am looking a solution if Tender Fee is marked as optional to get Create response button and Tender Fee option is to be also show in drop down of Related link.
    Vendor Portal:
    Purchaser Portal:

    I doubt there will be a 1 per customer rule....this wasn't the case with the iPhone 4 and that release may have been one worthy of it since it was the first time after years of wanting it Verizon customers were getting the chance to get their hands on one. But as far as the original question, yes you can get it. You are well within the exchange period so you can either exchange or just return it now and then buy the 4s on the preorder date...or the store release date. If you have any concerns about the possibility of not liking the 4s after getting it and wanting to be able to exchange it after that you might want to just return the iPhone(s) you have now and then buy the 4s when available. I say this because if you exchange now and then decide you don't care for the 4s you won't be allowed to exchange again to a different device. It won't matter if you love the 4s....matters a lot if you don't and end up stuck with it because of that one exchange policy.

  • IDCS4: Major bug creating interactive buttons

    I have a number of IDCS3 files with interactive buttons which jump to a specific page of the document using bookmarks. These buttons no longer work when the file is opened in IDCS4.
    In CS4, the button has a "Go to text anchor" action applied however the Text Anchor pop-up below is greyed out and says None. All the Bookmarks that I've created are present and correct. It would appear that CS4 is ignoring page bookmarks and will now only work with text anchors.
    This bug is also very easy to recreate with a new document in CS4:
    1. Create a new two page document.
    2. Go to page two and add a bookmark.
    3. Go to page one, create a button and add the "Go to Anchor" action.
    4. The Text Anchor pop-up should show the bookmark that was added it step 2 but it remains greyed-out.
    I've submitted this to Adobe and reverted back to using CS3 for any interactive work.
    Graham.

    Hi Sandee,
    Thanks very much for confirming the bug and for the workaround however this is a lot of work for my existing projects and easier to simple update them using CS3.
    Hmmmm... now, your comment "...bookmarks have never been recognized as part of making buttons." - try telling that to IDCS3, it even indicates that you've linked to a bookmark when you add a "Go to Anchor" behaviour to a button. I found this method more flexible and, to my simple way of thinking, more logical - a Bookmark goes to to a page in a document while a Hyperlink goes to a URL. For new CS4 projects I will now have to use the Hyperlink Destination (Type: Page) option instead. Oh well...
    So the problem isn't insurmountable for new projects but is still a bug in that it "breaks" legacy CS3 files opened in CS4 - and that's the argument I'll focus on when I hear back from Adobe.
    Cheers, Graham.

Maybe you are looking for