aspose file tools*
The moose likes Servlets and the fly likes Displaying the servlet from the servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Displaying the servlet from the servlet" Watch "Displaying the servlet from the servlet" New topic
Author

Displaying the servlet from the servlet

rekha devan
Greenhorn

Joined: Oct 10, 2005
Posts: 26
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?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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 ?


[My Blog]
All roads lead to JavaRanch
rekha devan
Greenhorn

Joined: Oct 10, 2005
Posts: 26
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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="...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying the servlet from the servlet