• 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

A problem using session?

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
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
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 .
reply
    Bookmark Topic Watch Topic
  • New Topic