You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Natasha Wright <to...@hotmail.com> on 2008/02/06 11:04:31 UTC

Servlet Openning as file download




From: toish100@hotmail.comTo: users@tomcat.apache.orgSubject: Date: Wed, 6 Feb 2008 10:00:53 +0000


HiI am running tomcat 5.5 on windows XP; I am attempting to run a servletas a html form action:<form method="POST" action="BeerSelect"><input type="SUBMIT"></form>When I click on the submit button a file download box appears where Ican 'save' the file "BeerSelect" as opposed to routing to the html page I createwithin the servlet class.  I've used tomcat before & have neverencountered this problem before & it does not seem to appear on anyforumMy web.xml contains the following:<web-app xmlns="http://java.sun.com/xml/ns/j2ee"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"    version="2.4"><servlet>            <servlet-name>Ch3Beer</servlet-name>            <servlet-class>com.example.web.BeerSelect</servlet-class></servlet><servlet-mapping>            <servlet-name>Ch3Beer</servlet-name>            <url-pattern>/BeerSelect</url-pattern></servlet-mapping></web-app>Any light anyone could shed on this would be much appreciated.Natasha Wright 

Re: Servlet Openning as file download

Posted by Juha Laiho <Ju...@iki.fi>.
Natasha Wright wrote:
> 
> 
> 
> From: toish100@hotmail.comTo: users@tomcat.apache.orgSubject: Date: Wed, 6 Feb 2008 10:00:53 +0000
> 
> 
> HiI am running tomcat 5.5 on windows XP; I am attempting to run a servletas a html form action:<form method="POST" action="BeerSelect"><input type="SUBMIT"></form>When I click on the submit button a file download box appears where Ican 'save' the file "BeerSelect" as opposed to routing to the html page I createwithin the servlet class.  I've used tomcat before & have neverencountered this problem before & it does not seem to appear on anyforumMy web.xml contains the following:<web-app xmlns="http://java.sun.com/xml/ns/j2ee"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"    version="2.4"><servlet>            <servlet-name>Ch3Beer</servlet-name>            <servlet-class>com.example.web.BeerSelect</servlet-class></servlet><servlet-mapping>            <servlet-name>Ch3Beer</servlet-name>            <url-pattern>/BeerSelect</url-pattern></servlet-mapping></web-app>A
ny light anyone could shed on this would be much appreciated.Natasha Wright 

Mm.. whatever you're using as your mail software is removing all line
breaks form your message, making it rather hard to read.

Anyway, as to your problem; most possibly it is that the BeerSelect servlet
(from Ch3Beer class) is setting some strange content type for the
response document (default content type is text/html, which should
be displayed just fine with the browser).

The other possible solution could be that even though your servlet is
setting text/html, it is outputting some non-html content, and because
of this your browser is deciding to rather offer to save the content
as opposed to displaying it directly.

You could also let your browser save the content and take a look at the
saved file to find out what your servlet actually did send as the
response to submitting the form.
-- 
..Juha

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org