aspose file tools*
The moose likes Servlets and the fly likes Sessions and Servlet not Jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sessions and Servlet not Jsp" Watch "Sessions and Servlet not Jsp" New topic
Author

Sessions and Servlet not Jsp

Sebastian Green
Ranch Hand

Joined: Jan 30, 2004
Posts: 136
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!


/ Sebastian<br />No blog, No homepage, No life?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61238
    
  66

What makes you think you need to do anything any different?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Siyaa Hoffman
Greenhorn

Joined: Jan 15, 2004
Posts: 23
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

Joined: Jan 30, 2004
Posts: 136
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.
 
subject: Sessions and Servlet not Jsp