File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A problem using session?

 
hany hashemi
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic