I was trying the the Mini MVC tutorial(chapter 3, BeerSelection) from Head First Servlet and Jsp book. From the form when I select a color, and press "submit" button, a "File download" dialoguge box appears which asks me whehter I want save SelectBeer.do file.
The form's action is SelectBeer.do and method=POST.
Is this something related with security seeting in my computer? I am very new to servlet programming. (using Tomcat, ant). Your help is appreciated
Mohammad, What I feel like that you r using Sruts. You have action classes in it which is responsible for the processing of the request. You might have invoked the dialog box that you r referring to in the action class. Check it out, and update it. -Navin.
Joined: Sep 09, 2004
Thanks for your reply. However I am not using struts. I am using tomcat 5.0.28. Using ant build.xml, I deployed the into /myapp context path. I am calling form.html using http://localhost:8080/myapp/form.html So if I choose "dark" from this form, I should get the output Got beer color dark So the servlet is not run.
I don't think that's the real problem in that. Giving out.println("<HTML>"); & out.println("</HTML>"); is not the real solution. I'm also using the same book for the reference and learning. I don't have to gave that two statements.
Actually while reviewing the code which you had placed in the post, I found that in your servlet you have used following
res.setContentType("/text/html"); which is wrong, it should be res.setContentType("text/html");
The "/"(forward slash) is creating the problem, i.e why you were getting the saving option.
The problem sounds a lot like improper configuration of your webapp. It needs to be configured mapping the .do to a specific resource which should them be setting the Response Header appropriately. Because the server isn't configured right, the response header gets set to unknown for the Mime type which causes the browser to save the response instead of displaying it.
Check the web.xml in your web application to see it matches what the book requires.