It's not a secret anymore!
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
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

making user enter the parameter of field in doGET

Sam Gill

Joined: Jun 06, 2003
Posts: 8
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:
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
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
In ur code instead of checking the name variable if its null u r checking for some passcode.Shouldn't it be name checking?
Max Haroot

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:
subject: making user enter the parameter of field in doGET
jQuery in Action, 3rd edition