• Post Reply Bookmark Topic Watch Topic
  • New Topic

About Forward() in servlet  RSS feed

 
sharma anurag
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all my Friends of javaranch.!!!

This is my code of LoginServlet which i forwarding to my RegisterServlet but it is going in my RegisterServlet check this code of mine.!!!


if anything is wrong in this than pleae modify it and send me and also tell me the reason ok.!!

Thanks in advance.!!
[ September 13, 2007: Message edited by: Bear Bibeault ]
 
poorna prakash parvathala
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi anurag

i guess you are forwarding the request before your performing login check

rd = req.getRequestDispatcher(path);
<b>rd.forward(req,res); </b>

if(user.equals("anurag")&&pass.equals("123"))
{
...
...
}

so, irrespective of your login information the request gets forwared to the logical path "/Register" only.
 
Krithika Srinath
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe in

String path = "/register";

register is your servlet name. In that case, since you are getting the dispatcher from the request, the path is already relative and you dont need to specify "/" unless you have it under a different directory.

For e.g., if register is the directory name where your RegisterServlet (actual servlet) exists, then your code should be

String path = "/register/RegisterServlet";
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sharma anurag,

Why are you ending every one of your sentences with double exclamation points (!!)?

Is it to create a sense of urgency in the readers mind?
If so, I have to tell you, for me anyway, it's having the opposite effect.
It's getting tiresome and making me not want to read or answer your posts at all.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!