wood burning stoves*
The moose likes Servlets and the fly likes making user enter the parameter of field  in doGET Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "making user enter the parameter of field  in doGET" Watch "making user enter the parameter of field  in doGET" New topic
Author

making user enter the parameter of field in doGET

Sam Gill
Greenhorn

Joined: Jun 06, 2003
Posts: 8
Hello,
My application requires user to enter a name and then shows the rows associated to that row in the text field form while posting the name in hidden field.
In my doPOST, user can make changes to those fields and press update and updates the row. MY problem is if a user presses update b4 entering any name, it should show an error.
This is wut i did in my dopost n doget method:
doget():
String name = req.getParameter("name");

out.println("<FORM method=GET name = \"AMember\" action=\"AMember\" >");
out.println("<INPUT type=text size=40 maxlength=20 name=name");
out.println("<INPUT type=submit value=\"Lookup Member\" ");
in my dopost
String name = req.getParameter("name");
if(passcode == null || passcode.equals(""))
{
out.println("Please enter the name and press LOOKUP MEMBER");
}
it compiles but if i hit the update b4 submit, it gives me empty field ( im assuming, it thinks it looks up fields for name = null rather than giving me an error)..Could you plz help me out with this. thanks!!
Pete Harris
Ranch Hand

Joined: Feb 05, 2003
Posts: 39
Sam,
I may be missing something here, but why not just use the javascript onsubmit() method to validate that the user has entered a name before the form is submitted?
cheers, Pete
Geeta Ramasami
Ranch Hand

Joined: Mar 05, 2003
Posts: 72
Hi,
In ur code instead of checking the name variable if its null u r checking for some passcode.Shouldn't it be name checking?
Cheers
Geeta
Max Haroot
Greenhorn

Joined: Jun 11, 2003
Posts: 3
If I understand correctly you are printing out the form name=\"AMember\" in your doGet. A user then submits that form and you expect that the doPost will be called.
If this is correct then form name=\"AMember\" method needs to be a POST, else you will never cause the doPost method to be invoked. Try changing the method to POST.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: making user enter the parameter of field in doGET