Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

making user enter the parameter of field in doGET

 
Sam Gill
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic