jQuery in Action, 3rd edition
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "A problem using session?" Watch "A problem using session?" New topic

A problem using session?

hany hashemi

Joined: Dec 17, 2008
Posts: 14
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:

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");



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.

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

Thanks in advance

[ 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


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

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

Joined: Jan 10, 2002
Posts: 63844

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] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: A problem using session?
It's not a secret anymore!