• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Displaying the servlet from the servlet

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have two files, one is the HTML file that prompts the user to enter some text in the textfield. When the user enters the text and clicks the submit button. A servlet is invoked to display the length of the servlet. Now after displaying the length, the servlet should prompt the user again to enter text.

Now what I am doing is I have a servlet to display the length and again below it I display a textbox prompting the user to enter text and then Submit button.When the user click on submit I invoke the same servlet again. When I try to invoke the servlet it gives 404 error.

What i wanted to know is

1. Is my logic right?
2. why is it giving 404 error?
3. If the logic is wrong what is the right way to do it?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should separate the "getting the length" logic,
and the "display the length" logic.

I think that you should get the length in the servlet,
put it in the response,
and redirect the response to a JSP file, containing the textfield.

JSP --submit-> Servlet --redirect--> JSP -- and so on -> ....

Do you have to stick to HTML, or can you use JSP instead ?
 
rekha devan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No i don't need to stick to HTML, I am just practicing.

But is it not possible to do

html->servlet->html->servlet.............?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you can. But I would not recommend using it to display dynamic content

Ok, let's go back to your 404 problem.
Can you post the action of your form ?
<form action="...
 
reply
    Bookmark Topic Watch Topic
  • New Topic