• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sessions and Servlet not Jsp

 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mange to handle sessions in my jsp-page but i would like to handle it with servlets instead. Here is my jsp code

Now what dose it take for me to get it going in "servletmode". I dont have J2EE installed but I have servlet-api.jar in my J2SDK. Could anyone help me out, what do I need to type in my jsp and java -file?

Thansk for your time!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What makes you think you need to do anything any different?
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sebastian,

In your servlet code, in the doGet() or doPost() method, you can get the session from the request object -

request.getSession() would give you the HttpSession. Then you can use the same API session.setAttribute() in the servlet code to set up the session level attribute.
Exactly what you are doing in the JSP.
[ June 01, 2004: Message edited by: Siyaa Hoffman ]
 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well thats the point, Im pretty new to this so Im having problems to communicate from the jsp to the servlet. So i thought a simple sessions example would do the trick. The answer I was looking for was more like: Here is the serlvet code:

package myfirstsession;
public class Site session {......

and here is the jsp code:

<%@ page import="myfirstsession.*" %>

I cant get it to work
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic