Getting Session Info In A Normal Class

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > JSP (Java Server Pages)

Getting Session Info In A Normal Class

cumanji
Hello, i want to get session info from a class that is not servlet (generally from in a bean). When we use servlets it is so easy to get session info by just using request.getSession() method. Is it possible to get this session info by importing a class?
We can get info about application config by using ServletConfig class. Is there a class to like ServletConfig to get info about session/application?

Reply

Ola Daniel
Technically there is no way to get the web session from a normal java class (POJO).


However if you wire your POJO into a web application using the J2EE MVC
pattern or FrontController pattern.i.e JSP submits to servlet, servlet passes the HttpServletRequest Object to POJO or bean. You can access your web session, your servlet context throught the request obejct.

I suggest you do some research on MVC and FrontController design patterns.

Reply

Andres Martinez Andrade
QUOTE(Ola Daniel @ Jun 15 2006, 03:43 PM) *
Technically there is no way to get the web session from a normal java class (POJO).
However if you wire your POJO into a web application using the J2EE MVC
pattern or FrontController pattern.i.e JSP submits to servlet, servlet passes the HttpServletRequest Object to POJO or bean. You can access your web session, your servlet context throught the request obejct.

I suggest you do some research on MVC and FrontController design patterns.


Does any one has an easy sample code to manage the session? I have done this only in php and I want to do the same with Java Server Pages.
I want to know how to create the session, how to destroy the current session and clear all variables, how to get the session id and how to read the session variables.

Thanks

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

Recent Queries:-
  1. getting session id java - 20.56 hr back. (1)
  2. getting session in java - 33.30 hr back. (2)
  3. java access session from a class - 41.28 hr back. (1)
  4. java web app get context in normal class - 47.12 hr back. (1)
  5. getting session object in java class - 50.91 hr back. (1)
  6. pojo session.get request - 60.55 hr back. (1)
  7. how do i access session info from a java class? - 71.56 hr back. (1)
  8. need to create httpservletrequest object in pojo class - 72.71 hr back. (1)
  9. getting session object in java - 118.27 hr back. (1)
  10. session info in java - 130.19 hr back. (1)
  11. session in java class - 186.02 hr back. (2)
  12. java how to get access to session in web pojo - 201.17 hr back. (1)
  13. get session for normal java class - 217.99 hr back. (2)
  14. "session from servlet context" - 227.59 hr back. (2)
Similar Topics

Keywords : session, info, normal, class

  1. Normal Maps In Blender
    Technique to make low resolutuion models have high resolution detail (6)
  2. Nfs: Undercover
    small info on the up coming game (0)
    QUOTE In what proved to be an incredibly newsworthy investors meeting EA boss John Riccitiello
    has unveiled details of the next Need for Speed game. Related Riccitiello seems confident Need for
    Speed Undercover, for that be its name, will be "a much better game" than a certain previous
    instalment in the series, thanks in part to a much richer storyline. He also won understatement of
    the day when he admitted last years Pro Street wasn't perhaps as good as it could have been. "I
    thought it was an okay game, in terms of gameplay. It's not good," "But who wan....
  3. My Experience With The Zlob Trojan
    Related to www.userads.info (1)
    Some of the following links point to websites that can harm your computer system. Please read
    the entire post first before clicking any links. Hello everyone, I recently had a run-in
    with a very annoying piece of malware on my home LAN network, and I wanted to share this experience
    with you so that you may avoid some of the mistakes I made. I'm on a home network which
    consists of 15 PCs, all running either Windows XP or Windows Vista. Most of the users are
    security-unaware and only a few have anti-virus or anti-spyware programs installed on their machi....
  4. Session Issues
    (1)
    I noticed this yesterday when I tried logging into my site at http://feral.portal.trap17.com/
    QUOTE Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0 Warning:
    Unknown: Failed to write session data (files). Please verify that the current setting of
    session.save_path is correct (/tmp) in Unknown on line 0 I know this isn't my issue because
    /tmp is a global server directory. Anyone else experiencing this?....
  5. Php Location Header No Send Session Id ?
    (0)
    Hi, All I got more question on header function. re-read the php documentation and notice an term
    that said as QUOTE Note: Session ID is not passed with Location header even if
    session.use_trans_sid is enabled. It must by passed manually using SID constant. What that
    means ? I have used two seperate script : src.php and target.php something like this: > CODE
    session_start(); header('Location: /target.php'); > CODE print_r($_REQUEST);
    But it does the session id sent back from server to client, then, it gets sent to server from b....
  6. Use Of Xml Properties File For One Key - Multiple Value Mapping
    - should I use some other Class? (0)
    Here is a situation I have encountered. I know I can write a custom code to get the job done, but I
    was wondering if the java.util.Properties class (or something else) had this inbuilt and I was
    missing it in the documentation. Situation: Need to load from a file, a set of values (mutliple
    values) for an associated single key. To illustrate, here is an example: propfile.properties
    CODE      barA1      barA2           barB1 The fooB=barB1 is a trivial case in
    implementing using the Properties class. But what about the multiple case - fooA= ? Ho....
  7. Changing Of Hosting Credit To Normal Forum Credit
    a request (1)
    I want to change the hosting credit system of now to normal forum credit or so the default in the
    very first subscription. How can I achieve this? Thank you for reading very post here.....
  8. Run A Script When Expires A Session
    (6)
    For example, when a user logins to a page -with a login form- and after validating and verifying
    it's credentials i store some information related to this user in session variables and a table
    with his state -connected- is updated, then i use it in other pages, etc. When this user logouts
    -by clicking a logout link- i release -unregister, destroy, etc- all the session variables stored
    and the same table is updated with his state -disconnected-. All of this funcionality works very
    well, the problem comes when the user do not click on the logout link and the session ....
  9. Session Save Path Not Set, Unwritable
    (8)
    Today while I was trying to install Mambo, I had problem with the Session Save Path setting.
    Everything else was green except that. It always said "Not Set, Unwritable ". After that, I
    tried searching at Google and found something about cinfiguring php.ini file in order to make it
    work. I haven't even heard of php.ini before so I don't know how to fix it. Thank you very
    much in advance. PS : Here is the link where I found the php.ini thing
    forum.joomla.org/index.php?topic=962.0 They were talking about Joomla but Mambo is much similar.....
  10. The Witcher Review
    Why can't normal life be like this? (1)
    I make a healing potion for a woman, I get laid. I save a woman from bandits, I get laid. I save
    some hookers from bandits, I get laid. I got laid 3 times last night in The Witcher, a RPG that was
    just released a bit ago. Apparently the US version is censored, so of course I got the UK import
    version. Only difference I believe are the "cards" you get when you receive "gratitudes" from women
    in this game. Of course, there's no actual "Sex" in game, just a card with a nude chick on it,
    marking your "conquest," but I guess the developers wanted to go with the saying "T....
  11. Php Session Problem
    (7)
    i have downloaded easyphp on my PC and i am a bit noob with php mysql commands. i have a problem
    making session work the problem that the session file in my server get deleted after leaving the
    page where the session was start for the first time. the problem that the session can only be used
    within the creation page unless you leave it. why?? i have no idea ... i have been looking around
    for three days now .. thank in advance for any help. if you need more details let me know
    /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />. Joe.k....
  12. Anyone Know Of A Really Good Mysql Class?
    Looking for something easy but full featured. (4)
    Generally speaking, when I write a script, it either utilizes the MySQL class of the parent system
    (like Mambo or Joomla) or I use basic functions and snippets to perform the database queries I need.
    I really like the Joomla database class as it allows you to simply pass a regular query string to
    it and the data is returned without the need for extra work! The Invision Power Board (IPB)
    database class which is what is used for this forum is kind of a pain to use since it wants the
    query string in a non-MySQL standard format. Nonetheless, it does work and I could use i....
  13. All About Databases
    Info, for you! (3)
    QUOTE Hi, I noticed there were a lot of questions in all of the database topics, so i went
    around the internet using different sources, and have some information that will answer your
    questions and help you understand databases. I hope this helps, and if you have any other questions
    which arent answered below, please send a message asking. Thankyou. In computing, a database can be
    defined as a structured collection of records or data that is stored in a computer so that a program
    can consult it to answer queries. The records retrieved in answer to queries become i....
  14. Already Sent Session Cookies?
    (2)
    Er, this is the second topic I've posted about session problems. Here's the html file that
    keeps showing up: CODE Warning: session_start() : Cannot send session cookie - headers already
    sent by (output started at C:\Program Files\xampp\htdocs\index2\loggingin.php:2) in C:\Program
    Files\xampp\htdocs\index2\loggingin.php on line 39 Warning: session_start() : Cannot send session
    cache limiter - headers already sent (output started at C:\Program
    Files\xampp\htdocs\index2\loggingin.php:2) in C:\Program Files\xampp\htdocs\index2\loggingin.php on
    line 39 Fatal ....
  15. [info] Security
    (4)
    Hi i was watching a program on T.V it was on channel 5 and it was like a crimewatch program and it
    had a bit on computers so here is some of it that i remember. Basically it was about security on
    routers so if you havent got a router then no point in reading this so here goes people can hack in
    to your network on a WEP code on certain program that they have got and they can get stuff like:
    What site you were on, Passwords, Personal infomation like Banks etc So when the professional
    security advisor came on he said that the best way of trying to stop this is to insert ....
  16. Basic Info & Download/ Installation Tutorial For Asp.net 2.0
    (1)
    Basic Info & Download/Installation Tutorial for ASP.NET 2.0 Well I received a book
    about ASP 2.0 and was ask to go over and review it later on which means test out the scripts that
    come with the book and what not. So far in my success in learning ASP I was able to download and
    install the proper software in order to get ASP running on a local machine (my computer) and so
    those who would like to ASP like I am somewhat. These series of tutorials that I will provide
    thanks to this book will give a general idea on how ASP works and build "robust" web appli....
  17. Need Info On Database Programming Courses
    Oracle Database Programming (2)
    I know Database Programming on MS-ACCESS, now i am planning to go for some other Database
    Programming courses, People told me to go for Oracle or VisualAge. Can anyone told me to start with
    which one and how long is the course period and which one is easy and is it similar to ms access or
    somthig different.....
  18. Disable Crash Recovery Restore Session Option On Firefox 2
    (3)
    Hi all, Guys frequently using Firefox 2 for browsing may notice one session recovery screen for
    restoring session on your browser after improper exit of the Firefox Browser or immediate shutdown
    while using Firefox! Firefox 2 will give an option to restore your browser session to previous
    state! So you may seen this screen before! /biggrin.gif" style="vertical-align:middle" emoid=":D"
    border="0" alt="biggrin.gif" /> Its one advantage of using Firefox 2! You can even go to your
    Gmail inbox without signing in after restoring the session! But imagine, if 2 or more us....
  19. Site Info
    (3)
    when I use my credits for the 30 cred site will I be able to see the stats on my site eg, number of
    visitors, page loads, hits... on some sites you can't so I was just wondering if you can on
    astahost. I am not hosted yet so to the ones who are please let me know. Merry Christmas and happy
    a new year. ....
  20. What Are Your Opinions On The Legalization Of Drugs?
    Request from a friend that is in a Drugs and Crime class (4)
    Forward: I received a request from a friend that is in a Drugs and Crime class. I spent about two
    hours on the response and I didn’t want all the typing to go to waste so I decided to throw it in
    here. Too bad there is no post count here; this would set me for a month. Question: What are your
    opinions on the legalization of drugs and why do you feel that way? I hope you were expecting a
    counter argument to the traditional arena of thinking regarding drugs because that is what I am
    offering. I am currently at work so my research into some of the facts presented may....
  21. Smf Theme Creation Help
    CSS class/id for changing the colour of lower edge of header objects (13)
    I would require a forum in the near future for another of my project. I had tried my hand at phpBB
    and found that it had excessively high number of templage (.tpl) files, and I could not easily skin
    it. Next, I installed SMF on my local server, and am creating a new theme. I created a new theme
    out of the default theme, and started to change the colours for all elements. I have got almost all
    of what I want, except for one thing. Here is what I have in the header: I need to change that
    gray area in the bottom edge of the special header boxes. What property in ....
  22. Alienware New Facelift...
    Anyone have any info on Alienware's new facelift? (4)
    I recently just purchased an Alienware desktop system, and after about 2 months or so they released
    a brand new shell for the system with new features. Im not much of a hardware person so anyone that
    knows the in and outs of Alienware, do you know how much they improved on their new realeased
    desktop systems?....
  23. How To Delete Files When Session Ends
    (4)
    Dear Friends I need solution to a problem. The problem is as under: I am creating certain files
    (playlist) in server disk when user selects some songs. The files are created in ram format. What I
    want to do is to delete these files created during a particular session. Is it possible to do so?
    Now I am deleting these files using on Unload event fired by JavaScript. I am using PHP. ....
  24. User Authentication Session Handling Problems
    Authorization server variables not staying across pages (14)
    This is quite a bit of problem I am facing, and I cannot point exactly where I am going wrong. I
    have been lurking around here at the Asta Host forums with regard to login and user authentication
    scripts and I have got as far as this: - Starting a session - Registering a session variable -
    Using the variable to check if the user is authenticated or not. - Authenticating the user through
    MySQL database - Logging of the user, by setting the session variable to un-authenticated I have
    been able to achive the following things too that I think is not related to this proble....
  25. Session And Security
    (0)
    Hi everyone, I'd like to explain my idea for basic session handling to you guys. I've
    thought about it, and I can't see any problem with it, but I'd like other's opinions as
    well, please. Ok, here goes. So basically, there's two base cases that can happen. User
    visits any page, session class is initialized, etc. Case 1 - User not logged in; no cookie or
    session info in DB If the user is not logged in, has no cookie, and/or there is no session info in
    the DB for this user, any specified activities, protected like so: php: if ( $session....
  26. Problem: Account Info
    (5)
    Hello, As my account g2k.astahost.com has been approved but i did not get any email regarding my
    account information. I havent received a single email from astahost i have checked my junk folder as
    well. Please help me out, My email addresses are redfeilds18@hotmail.com maverick_02_6@hotmail.com
    Thanks....
  27. Can I Put Adsense Ads On My Site At Astahost?
    Google Adsense Info (7)
    Hi Everybody, Just a few things, particularly on Adsense. Does this hosting server allow
    adsense code? My friend has been using adsense for 2 days now and it says he has made $17.38. If you
    didn't include taxes, would this be the actual amount he is paid? BTW im not trying to get
    hosted here for adsense, but its a nice little bonus /smile.gif" style="vertical-align:middle"
    emoid=":)" border="0" alt="smile.gif" /> So far I am very impressed with altahosts professionalism,
    and i really hope i can get hosted here soon =] ~Adio....
  28. Need Help - How To Remove Session ID From URL
    (6)
    Oflate I was going through Google information for webmasters and I noticed the following technical
    guideline for the webmasters: QUOTE Allow search bots to crawl your sites without session IDs or
    arguments that track their path through the site. These techniques are useful for tracking
    individual user behavior, but the access pattern of bots is entirely different. Using these
    techniques may result in incomplete indexing of your site, as bots may not be able to eliminate URLs
    that look different but actually point to the same page. It clearly shows that undesir....
  29. Total Free Top Level Domain Names!
    .com/.net/.org/.info/.ws/.us domains!!!! (10)
    Do not put false advertising in your Posts QUOTE ONEsite Free Hosting* Hosting Club Cost  
    * $0.00    $35/year Storage   50 MB    100 MB Transfer   3 GB/mo     5 GB/mo Email Accounts
      5    10   Support  No    24x7 Phone and Priority Ticket   PHP/SSI  Yes    Yes   CGI   
    No    Yes   Frontpage  Yes    Yes   SiteBuilder  Yes    Yes All ONEsite customers are
    required to perform the following: • Build a website within the first 30 days. • Log into the
    toolbar on a weekly basis • Setup Email at your ONEsite domain or forward all email to you....
  30. Php, Sql Lite: Storing Session's Data?
    how so store session in SQLITE? (1)
    normally, in windows, session data is saved in the location as directed by the "session.save_path"
    directives. they only show how to store session data in file. is it possible to store it inside the
    SQLite? anyone?....

    1. Looking for session, info, normal, class






*SIMILAR VIDEOS*
Searching Video's for session, info, normal, class
Similar
Normal Maps In Blender - Technique to make low resolutuion models have high resolution detail
Nfs: Undercover - small info on the up coming game
My Experience With The Zlob Trojan - Related to www.userads.info
Session Issues
Php Location Header No Send Session Id ?
Use Of Xml Properties File For One Key - Multiple Value Mapping - - should I use some other Class?
Changing Of Hosting Credit To Normal Forum Credit - a request
Run A Script When Expires A Session
Session Save Path Not Set, Unwritable
The Witcher Review - Why can't normal life be like this?
Php Session Problem
Anyone Know Of A Really Good Mysql Class? - Looking for something easy but full featured.
All About Databases - Info, for you!
Already Sent Session Cookies?
[info] Security
Basic Info & Download/ Installation Tutorial For Asp.net 2.0
Need Info On Database Programming Courses - Oracle Database Programming
Disable Crash Recovery Restore Session Option On Firefox 2
Site Info
What Are Your Opinions On The Legalization Of Drugs? - Request from a friend that is in a Drugs and Crime class
Smf Theme Creation Help - CSS class/id for changing the colour of lower edge of header objects
Alienware New Facelift... - Anyone have any info on Alienware's new facelift?
How To Delete Files When Session Ends
User Authentication Session Handling Problems - Authorization server variables not staying across pages
Session And Security
Problem: Account Info
Can I Put Adsense Ads On My Site At Astahost? - Google Adsense Info
Need Help - How To Remove Session ID From URL
Total Free Top Level Domain Names! - .com/.net/.org/.info/.ws/.us domains!!!!
Php, Sql Lite: Storing Session's Data? - how so store session in SQLITE?
advertisement




Getting Session Info In A Normal Class