What's the best way to check whether a user is logged in or not?

I have a question about basic session handling.
I'm running Tomcat 5.0.30 and have a web application where users can register with a username and password, and then log into a "member site".
What is the best way of making sure that a user actually has logged in or not?
What I've done in previous applications I've made is that I've just put a simple variable into the users session after he has successfully entered his password (i.e. Boolean loggedIn=true). Then I just test if this flag is true to grant him access to the member site. Is that a smart way of doing it?
Are there any libraries I can use which handles sessions for me in a secure way?
All comments and suggestions are appreciated!

Maintain a flag using session attributes it to one when the user is logs in set it to value.... and change set it zero or invalidate that session... when the user is logged out...
use something like this while user had logged in
session.setAttribute("flag",<unique_number>);
for checking whether the user had logged in or not...
if(Integer.parseInt(session.getAttribute("flag").toString())=!<unique_number>){
out.println("The session had expired");
out.close();
}

Similar Messages

  • I am getting pop ups on safari and firefox lately and am worried i may have malware or something now on my computer doing this. What is the best way to check this out for sure and remove it?

    I am getting pop ups on safari and firefox lately and am worried I may have malware or something now on my computer doing this. What is the best way to check this out for sure and remove it?

    Please review the options below to determine which method is best to remove the Adware installed on your computer.
    The Easy, safe, effective method:
    http://www.adwaremedic.com/index.php
    If you are comfortable doing manual file removals use the somewhat more difficult method:
    http://support.apple.com/en-us/HT203987
    Also read the articles below to be more prepared for the next time there is an issue on your computer.
    https://discussions.apple.com/docs/DOC-7471
    https://discussions.apple.com/docs/DOC-8071
    http://www.thesafemac.com/tech-support-scam-pop-ups/

  • What is the best way to merge a file content into log file

    What is the best way to merge a file content into log file.
    In worst case, I will read the file line by line as string, then use
    logger.info(lineString)to output to log file.
    However, is there better way to do this?
    The eventual log file will be something like:
    log message 1
    log message 2
    content from file line 1
    content from file line 2
    content from file line 3
    log message 3
    log message 4Thanks

    John618 wrote:
    Thank you and let me explain:
    1. What do you mean by better?
    I would like to see better performance. read line by line and log each line as string can be slow. Did you measure this and determine that it is actually a problem for your application? Or are you guessing?
    Regardless of what you do you are still going to need to read the file.
    >
    2.The only better way I can think of is not having to do it, but I assume you have a very good reason to want to do this.
    Yes, I have to do it beacuse the requirement is to have that file content be part of logging.
    Any idea?How is it supposed to be part of it? For example which of the following is better?
            File AAA - contents
                       First Line
                       Second Line XXX
            Log 1
                    2009-03-27 DEBUG: Random preceding line
                    2009-03-27 DEBUG: First Line
                    2009-03-27 DEBUG: Second Line XXX
                    2009-03-27 DEBUG: Random following line
            Log 2
                    2009-03-27 DEBUG: Random preceding line
                    2009-03-27 DEBUG: ----- File: AAA -------------
                    First Line
                    Second Line XXX
                    2009-03-27 DEBUG: Random following lineBoth of the above have some advantages and disadvantages.
    The first in a mult-threaded app can end up with intermittent log entries in between lines, so having log lines with thread ids becomes important.
    The first can be created by reading one line at a time and posting one at a time.
    The second can be created by reading the entire file as a single string and then posting using a single log statement.

  • What is the best way to display errors to users when using JSPs?

              Hello,
              Could someone suggest me the best way to display errors to users when using JSPs?
              Many thanks in advance.
              Rino
              

              Thanks for the code snippet!
              Rino
              "Deepak Vohra" <[email protected]> wrote:
              >
              >
              >The 'errorPage' attribute of the 'page' directive forwards uncaught run-time
              >exceptions
              >to an error processing page. For example:
              >
              ><%@ page errorPage="error.jsp" %>
              >
              >redirects the browser to the JSP page error.jsp if an uncaught exception
              >is encountered.
              >
              >
              >Within error.jsp, indicate that it is an error-processing page, via the
              >directive:
              >
              >
              >
              ><%@ page isErrorPage="true" %>
              >
              >The Throwable object describing the exception may be accessed within
              >the error
              >page via the 'exception' implicit object.
              >
              >
              ><% if (exception != null) { %>
              ><p> An exception was thrown: <b> <%= exception %>
              >
              ><p> With the following stack trace:
              ><pre>
              >
              ><%
              > ByteArrayOutputStream ostr = new ByteArrayOutputStream();
              > exception.printStackTrace(new PrintStream(ostr));
              > out.print(ostr);
              >%>
              ></pre>
              >
              >
              >
              >"Rino Srivastava" <[email protected]> wrote:
              >>
              >>Hello,
              >>
              >>Could someone suggest me the best way to display errors to users when
              >>using JSPs?
              >>
              >>Many thanks in advance.
              >>
              >>Rino
              >
              

  • Mac Pro won't start up.  What's the best way to check the power supply?

    Hello. I'm having a severe problem with my 2007 Mac Pro. The symptoms are very easy to describe. The computer apparently shut itself off overnight, and when I press the power button to turn it on, absolutely nothing happens. No lights, no chime, no signs of any power whatsoever in the computer. I have never had major problems with the computer before. (Although I had recently noticed some minor skipping problems with streaming videos and Firefox had started hanging occasionally.)
    So far, I have checked the power cable and the power outlet. I have also reset the SMC (holding in the Power button for 5 seconds with the unit unplugged). I am unable to see any light in the diagnostic LEDs (including LED 1) when I press the DIAG_LED button on the logic board.
    While I welcome other suggestions, all I can figure is that this is either a power supply problem or a major logic board failure, but I don't know which. I have a multimeter and would like to test very directly if the power supply is the problem, because they are very expensive and obviously I do not want to order a replacement supply if it would not fix the computer. Does anyone know what the best way to test the supply directly is? What pins on what cable should I test, and what voltage should I look for?
    Also: No the computer is not under any warranty. If at all possible, I would like to fix this myself. Thanks for any help you can give.

    Well, I may have found the answer to my question as to why replacing the fuse dows not seem to be encouraged. I cut out the failed fuse (fast fuse, ceramic, 16 Amp 250V), and replaced it with another that was as close to it in spec as I could find (15 A instead of 16). Then I put the supply back in the case.
    When I tried to plug it in, I got an immediate spark, followed by an acrid smell from the power supply. Later inspection revealed that the new fuse blew, as did another component nearby (not sure what it was) where I could see blackening and the smell was concentrated. At this point, I would consider myself lucky if the power supply didn't take anything else on the computer out with it.
    Lesson learned; will try a new power supply and go from there.

  • What's the best way to know whether an application is running for the first time? (C#)

    I seen suggestions like making a registry entry, or making an entry in the application specific settings file. But what's the best practice? I want to do some custom tasks if that is a first run.
    Also, I am deploying my application using per machine MSI installer. So un-installation not deleting the user specific config files that's get created under AppData.
    Thanks Prasad

    Hello,
    Whenever possible I prefer to avoid the registry. The following works once per user where we see if a specific folder exists or not, if it does not then do first time initialization work then set a setting in the project which causes a user config file to
    be written to the location for storing user settings per user. 
    You first need to create a setting in the project, in this case I did
    var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
    string configPath = config.FilePath.Replace("\\user.config", "");
    if (System.IO.Directory.Exists(configPath) )
    Console.WriteLine("This is not the first time");
    else
    // Do one time setup here
    Properties.Settings.Default.FirstTimeValue = "1";
    Properties.Settings.Default.Save();
    Console.WriteLine("This was the first time");
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • What's the best way to check my macbook pro for malware?

    I've noticed of late a couple of random popups and suspicious-looking installers on my macbook pro. How can I check for malware? And if my lap top's infected, how can I disinfect it?

    There is no need to download anything to solve this problem. Your desciption isn't very specific, but I'll venture a guess.
    You may have installed the "Genieo" or "InstallMac" ad-injection malware. Follow the instructions on this Apple Support page to remove it.
    Back up all data before making any changes.
    Besides the files listed in the linked support article, you may also need to remove this file in the same way:
    ~/Library/LaunchAgents/com.genieo.completer.ltvbit.plist
    If there are other items with a name that includes "Genieo" or "genieo" alongside any of those you find, remove them as well.
    One of the steps in the article is to remove malicious Safari extensions. Do the equivalent in the Chrome and Firefox browsers, if you use either of those.
    After removing the malware, remember to reset your home page in all the web browsers affected, if it was changed.
    If you don't find any of the files or extensions listed, or if removing them doesn't stop the ad injection, then you may have one of the other kinds of adware covered by the support article. Follow the rest of the instructions in the article.
    If you find Apple's instructions too hard to follow, ask for an alternative that doesn't require you to trust a black-box application without knowing what it does.
    Make sure you don't repeat the mistake that led you to install the malware. Chances are you got it from an Internet cesspit such as "Softonic" or "CNET Download." Never visit either of those sites again. You might also have downloaded it from an ad in a page on some other site. The ad would probably have included a large green button labeled "Download" or "Download Now" in white letters. The button is designed to confuse people who intend to download something else on the same page. If you ever download a file that isn't obviously what you expected, delete it immediately.
    In the Security & Privacy pane of System Preferences, select the General tab. The radio button marked Anywhere  should not be selected. If it is, click the lock icon to unlock the settings, then select one of the other buttons. After that, don't ignore a warning that you are about to run or install an application from an unknown developer.
    Still in System Preferences, open the App Store or Software Update pane and check the box marked
              Install system data files and security updates (OS X 10.10 or later)
    or
              Download updates automatically (OS X 10.9 or earlier)
    if it's not already checked.

  • What is the best way to prompt a Form user to enter a value

    Hi,
    I apologize in advance if this topic has already been raised on the forum - I've done a search but couldn't find anything.
    Basically I would be interested in finding out if there is a 'best way' to prompt and accept an entered value from a user. I am just experimenting at the moment with asking a user to enter a date value which will then be used in code. I am running Form 9.0.4.
    Any suggestions or links would be gratefully accepted,
    regards,
    Kevin.

    I am rather puzzled by the question. Forms primary use is to accept user input, and then respond to that input. It is no wonder a search does not turn anything up.
    So there are a number of ways to accept input. The first that comes to mind is a simple input field on the canvas with some prompt text next to it.
    I don't think there really is a "best practice". It really depends on what your form is doing.
    If you explained what you mean by "which will then be used in code", or described what your form needs to do, then you would get some good suggestions.

  • What's the best way to remove inactive iChat users from jabberd2.db?

    I'm about to run Autobuddy for users on my iChat server. However, there are several users that are no longer around and I don't want their records showing up in everyone's buddy list.
    What's the safest/best way to remove them?
    My plan is to use sqlite3 on the command line and use SQL to remove the entries from the "active" table, but I don't know what impact that may have on the rest of the database.
    Any thoughts or suggestions?

    Never mind...
    Thought I had looked through enough threads.  Found the following just after posting my question:
    /usr/bin/jabber_autobuddy -d [email protected]
    Works like a charm.

  • What's the best way to check what's on my hard drive?

    Hello Everyone...
    I'm fairly new to the mac experience so I apologize in advance if this information is readily available elsewhere...
    I'm trying to find out what is taking up the most space on my hard drive with hopes to move or delete files... I did several searches here on the forums and well as googled and came up with some freeware programs like Disk Inventory X, What Size?, and Omni... Any opinions on what works best? or any other ways I can find these files? Thanks for the help...

    The following articles have some good tips:
    Freeing space on your Mac OS X startup disk
    Freeing Up Hard Disk Space
    Running maintenance routines is critical to keeping the drive clear of unneccesary files:
    http://www.macworld.com/2005/01/features/preventmacdisasters/index.php
    http://www.thexlab.com/faqs/maintscripts.html
    Since you're a newcomer to the Mac, see these:
    Switching from Windows to Mac OS X,
    Basic Tutorials on using a Mac,
    MacFixIt Tutorials,
    MacTips, and
    Switching to the Mac: The Missing Manual, Leopard Edition.
    Additionally, *Texas Mac Man* recommends:
    Quick Assist.
    Welcome to the Switch To A Mac Guides, and
    A guide for switching to a Mac.

  • What's the best way to eliminate and old user's information completely?

    My son recently purchased a new macbook pro and I would like to use his 3 year-old macbook as a back-up for home use. Is there a recommended method of eliminating all of his preferences and data? He has already transferred what he needs to his new computer and I want to clean this off as much as possible before adding myself as a new user. It's the white plastic model.

    Log into his account on the computer. Open Accounts preferences and create a new account for yourself. Be sure to endow the account with admin privileges and in Login Options set your account for auto-login. Then log out of your son's account and log into the new account you made for yourself. Open Accounts preferences and delete your son's account. Open Sharing preferences and change the Computer Name to one of your choice.

  • Best way to check whether the database is demo or sys?

    Hi Gurus,
    Whats the best way to check whether the installed peoplesoft database is a demo or a sys?
    Thanks for the help?
    Regards,
    Anoop

    There is nothing set by default.
    However, if it has been configured properly by the administrator after db creation, through the menu Peopletools>Utilities>Administration>Peopletools Options, the following query should return the type of the database :
    select systemtype from psoptions;Otherwise the following could help to understand what database you are on.
    From HRMS9.1 DMO database :
    SQL> select count(*) from ps_employees;
          2792From HRMS9.1 SYS database :
    SQL> select count(*) from ps_employees;
      COUNT(*)
             0Nicolas.

  • What is the best way to create 10000 users in ECC system

    Dear all,
    what is the best way to create 10,000 users in ECC 6 system.
    As of my knowledge we can create with SECATT, but I don't know the procedure to use this.
    please guide me...
    Regards,
    Raaja

    Hi Raaja,
    If you search in SDN or on google for eCATT tutorial, you will get all the info you need to learn to create them.
    For 10000 users I would suggest the following
    1. eCATT to create user ID's (include all the info like passwords, user groups in here).
    2. eCATT to make the role assignment.  Use SU10 to record the assignment to the users you created with the first script as it gives you more flexibility
    If you have the data you need then you should be able to run both steps in 1 work day (dependent on system performance).
    Edited by: Alex Ayers on Jan 25, 2009 11:16 AM

  • What is the best way to watch cricket on line in Mac Book pro

    what is the best way to watch cricket online in Mac Book Pro

    This is not a place where we discuss about sports, google is a nice place to find a good website.

  • UI design - what is the best way to allow the user to set some kind of infusion at varying (non periodic) times?

    I want to allow the user to specify a curve like this:
    Such that some subVI outputs the value A2 when a time variable is within the range R1, A1 when the time variable is within the range R2, and A3 when the time is within the range R3.
    My design looks something like this:
    With error checking that looks like this:
    My question is, is the array based approach optimal? How else could I tackle this?

    I think I can summarize the conversation to this point as an answer to the original question (What is the best way ...) -- before starting to write any code, think carefully about what you want to accomplish, and write it down (otherwise known as "Write the Documentation First").  One of the points of a good User Interface is that it doesn't allow users to "make silly mistakes" -- it leads the user "by the hand", restricting the entries to "legal values" and requiring that entries be made in a logical manner.
    So if you were going to have a list of Infusions to enter, it makes sense to decide on whether to enter Time Intervals (which are always >0) or Times (which, logically) are always in ascending order.  You can (and should) decide which you want (or you could have a control that would let the User decide, but that might be too flexible) and then enforce your "rules".
    Suppose you decided on "Intervals" (which seems, to me, to be more User Friendly).  After the User has entered the intervals (and you've provided a nice plot of Infusion vs Time), you could allow the User to "split" an Interval, "Remove" an Interval, or "Edit the Infusion" of an Interval, or you could decide to have a simpler "Accept or Start Over" choice -- if you only have a few intervals, the last might be the simplest (and thus the Best) Design Choice.
    Spending more time thinking before coding usually pays Big Dividends!
    Bob (speaking from Sad Experience) Schor

Maybe you are looking for