Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Unable to understand the flow of simple app  RSS feed

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
New bee to Servlets.

Flow: index.html -->GreetingServlet -->sucess.html

fields: (in index.html)
firstname: txtbox
surname: txtbox
submit button

GreetingServlet checks below:


sucess.html: plain html page

web.xml:



index.html:



my understanding of application flow is : When i click on submit button, depending on the name mentioned for action attribute in index.html file corresponding <servlet-name> is checked in the web.xml file. and the particular servlet processes the request as per the method attribute mention in the index.html.

Am i write?

Also want to know how the execution proceeds when i replace with "/GreetingServlet" for action attribute in the index.html page as I get an error and not able to proceed
 
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are absolutely not rong, sorry, wrong.

That is what is happening. You post the fields in a query string to the Servlet that answers on the pattern /GreetingServlet. It then processes the request, like looking for the mandatory name fields.

I don't know how the rest of your Servlet class post-method looks like. But that should work. If you change the action url, then you also need to change or add the mapping to the servlet so that it knows that it is supposed to react on the call.

And one little thing... try to use positive programing.

The code:


should, imho, be rewritten as

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!