• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

making user enter the parameter of field in doGET

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic