aspose file tools*
The moose likes Servlets and the fly likes A problem using session? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "A problem using session?" Watch "A problem using session?" New topic
Author

A problem using session?

hany hashemi
Greenhorn

Joined: Dec 17, 2008
Posts: 14
Hi,
I have a page named "Login" and after entering username and password , a user can enter into a page named "MainMenu".So simple..
I am going to use session so when a user login and enter into a MainMenu and after that close this page,with opening new page the controller set if it is a new session forward it to "Login" , otherwise forward the request to the "MainMenu" or each page that a user was in before closing the page.
Here is my code:

[CODE]
if (session.isNew()){ // the first login
getServletConfig().getServletContext().getRequestDispatcher ("/Login.html").forward(request,response);
currentUrl = getUrl(request);

}
else {
oldUrl =(String) session.getAttribute("currentUrl");
String servletPath = request.getServletPath(); // /control

if (oldUrl != null) {
// out.println("oldUrl != null");
getServletConfig().getServletContext().getRequestDispatcher("\"servletPath").forward(request,response);
}

}
session.setAttribute("currentUrl",currentUrl);
out.close();

}
[CODE]

but unfortunately it doesn't work and i face to this error:

type: Exception report
message escription The server encountered an internal error () that prevented it from fulfilling this request.

exception:
java.lang.IllegalArgumentException: Path "servletPath does not start with a "/" character

Thanks in advance
Hany

[ December 23, 2008: Message edited by: Bear Bibeault ]
[ December 24, 2008: Message edited by: hany hashemi ]
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458

getServletConfig().getServletContext().getRequestDispatcher("\"servletPath").forward(request,response);


java.lang.IllegalArgumentException: Path "servletPath does not start with a "/" character

Isn't the exception self-explaining?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A problem using session?