Jsp files download message!!! URGENT

Hi,
Does anyone have an idea about why I'm getting a download message when I try to run my jsp file deployed on OC4J?
Seems to be a problem with parameters:
This is what I do in my code:
pageContext.forward("pag_loginc.jsp?p_idusr=" + strUsr + "&c_password=");
And then I get a window for saving pag_loginc.jsp

Yes,
Works just fine. Which gui were you talking about. I did it through the webui.
Check out the ora iFS User's Guide. pp 3-10 to 3-14.
Good luck.

Similar Messages

  • Questions regarding jsp file download from blob

    Hi developers, i'm doing jsp file download from a blob column in DB2 using struts,
    1) How do i design the jsp page such that the page will show perhaps a hyperlink for me to download the file?
    2) What about struts-config.xml? Do i need to modify any mappings there?
    It would be great if some kind developers were to provide some sample codes for me. Thanks alot. Your effort is kindly appreciated.

    http://kr.forums.oracle.com/forums/thread.jspa?threadID=1982213 - looks similar, you may need to change contentType as per use case

  • What's wrong with the JSP files?? Urgent Help Request

    I have run some JSP files using Apache Tomcat 4.0 but I see many similar error message for the JSP files when running on the IE. I don't whether I should install some other software or components or just program errors in the JSP files.
    The error messages are as follows:
    javax.servlet.ServletException: oracle/xml/parser/v2/XMLParseException
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:457)
         at org.apache.jsp.edit_0005fquiz_0005flist$jsp._jspService(edit_0005fquiz_0005flist$jsp.java:154)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
         at java.lang.Thread.run(Thread.java:536)
    root cause
    java.lang.NoClassDefFoundError: oracle/xml/parser/v2/XMLParseException
         at EntityBase.(EntityBase.java:18)
         at QuizGen.(QuizGen.java:16)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
         at java.lang.Class.newInstance0(Class.java:296)
         at java.lang.Class.newInstance(Class.java:249)
         at java.beans.Beans.instantiate(Beans.java:204)
         at java.beans.Beans.instantiate(Beans.java:48)
         at org.apache.jsp.edit_0005fquiz_0005flist$jsp._jspService(edit_0005fquiz_0005flist$jsp.java:122)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
         at java.lang.Thread.run(Thread.java:536)
    And the reference JSP file is:
    <%@page language="java" import="java.io.*, java.sql.*, DBSession, QuizGen"%>
    <jsp:useBean id="sess" scope="session" class="DBSession"/>
    <jsp:useBean id="quizGen" scope="session" class="QuizGen"/>
    <%@include file="common.jsp"%>
    <%
    quizGen.setSession(sess);
    quizGen.build();
    quizGen.print(new PrintWriter(out), this.getURLPath(request, "edit_quiz_list.xsl"));
    %>
    another JSP file:
    <%@page language="java" import="java.io.*, java.sql.*, eQuizMetadata"%>
    <jsp:useBean id="eQuiz" scope="session" class="eQuizMetadata"/>
    <%@include file="common.jsp"%>
    <%
    Integer nextQues = (Integer) session.getAttribute("eQuiz_nextQues");
    session.setAttribute("eQuiz_nextQues", new Integer(nextQues.intValue()+1));
    if (nextQues.intValue() > 0) {
    if (request.getParameter("QueType").equals("F")) {
    eQuiz.checkAnswer(request.getParameter("answer"));
    else{
    if (request.getParameter("QueType").equals("H")) {
    eQuiz.checkAnswer(request.getParameter("map"));
    else{
    if(request.getParameter("QueType").equals("A")) {
    String sAns = "";
         if (request.getParameter("MAT1") != null) sAns += request.getParameter("MAT1");
         if (request.getParameter("MAT2") != null) sAns += request.getParameter("MAT2");
         if (request.getParameter("MAT3") != null) sAns += request.getParameter("MAT3");
         if (request.getParameter("MAT4") != null) sAns += request.getParameter("MAT4");
         eQuiz.checkAnswer(sAns);
         else{
              if (request.getParameter("Cardinality").equals("S"))
              eQuiz.checkAnswer(request.getParameter("MC"));
              else {
              String sAns = "";
              if (request.getParameter("MR1") != null) sAns += request.getParameter("MR1");
              if (request.getParameter("MR2") != null) sAns += request.getParameter("MR2");
              if (request.getParameter("MR3") != null) sAns += request.getParameter("MR3");
              eQuiz.checkAnswer(sAns);
    eQuiz.calAbility();
    // meet one of the stopping criteria?
    if (eQuiz.checkStopQuiz()) {
    %>
    <jsp:forward page="eQuiz_result.jsp"/>
    <%
    %>
    <html>
    <head>
    <title>QuizML Management System</title>
    </head>
    <frameset border="0" rows="30,*">
    <frame src="eQuiz_head.jsp" name="head" noresize scrolling="no">
    <frame src="eQuiz_detail.jsp" name="detail" scrolling="auto">
    </frameset>
    </html>

    root cause
    java.lang.NoClassDefFoundError: oracle/xml/parser/v2/XMLParseExceptionYou simply don't have the "oracle.xml.parser.v2.XMLParseException" class in your classpath at run-time.

  • What's wrong with the JSP file??Urgent Help Request

    I have run some JSP files using Apache Tomcat 4.0 but I see many similar error message for the JSP files when running on the IE. I don't whether I should install some other software or components or just program errors in the JSP files.
    The error messages are as follows:
    javax.servlet.ServletException: oracle/xml/parser/v2/XMLParseException
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:457)
    at org.apache.jsp.edit_0005fquiz_0005flist$jsp._jspService(edit_0005fquiz_0005flist$jsp.java:154)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
    at java.lang.Thread.run(Thread.java:536)
    root cause
    java.lang.NoClassDefFoundError: oracle/xml/parser/v2/XMLParseException
    at EntityBase.(EntityBase.java:18)
    at QuizGen.(QuizGen.java:16)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
    at java.lang.Class.newInstance0(Class.java:296)
    at java.lang.Class.newInstance(Class.java:249)
    at java.beans.Beans.instantiate(Beans.java:204)
    at java.beans.Beans.instantiate(Beans.java:48)
    at org.apache.jsp.edit_0005fquiz_0005flist$jsp._jspService(edit_0005fquiz_0005flist$jsp.java:122)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
    at java.lang.Thread.run(Thread.java:536)
    And the reference JSP file is:
    <%@page language="java" import="java.io.*, java.sql.*, DBSession, QuizGen"%>
    <jsp:useBean id="sess" scope="session" class="DBSession"/>
    <jsp:useBean id="quizGen" scope="session" class="QuizGen"/>
    <%@include file="common.jsp"%>
    <%
    quizGen.setSession(sess);
    quizGen.build();
    quizGen.print(new PrintWriter(out), this.getURLPath(request, "edit_quiz_list.xsl"));
    %>
    another JSP file:
    <%@page language="java" import="java.io.*, java.sql.*, eQuizMetadata"%>
    <jsp:useBean id="eQuiz" scope="session" class="eQuizMetadata"/>
    <%@include file="common.jsp"%>
    <%
    Integer nextQues = (Integer) session.getAttribute("eQuiz_nextQues");
    session.setAttribute("eQuiz_nextQues", new Integer(nextQues.intValue()+1));
    if (nextQues.intValue() > 0) {
    if (request.getParameter("QueType").equals("F")) {
    eQuiz.checkAnswer(request.getParameter("answer"));
    else{
    if (request.getParameter("QueType").equals("H")) {
    eQuiz.checkAnswer(request.getParameter("map"));
    else{
    if(request.getParameter("QueType").equals("A")) {
    String sAns = "";
    if (request.getParameter("MAT1") != null) sAns += request.getParameter("MAT1");
    if (request.getParameter("MAT2") != null) sAns += request.getParameter("MAT2");
    if (request.getParameter("MAT3") != null) sAns += request.getParameter("MAT3");
    if (request.getParameter("MAT4") != null) sAns += request.getParameter("MAT4");
    eQuiz.checkAnswer(sAns);
    else{
    if (request.getParameter("Cardinality").equals("S"))
    eQuiz.checkAnswer(request.getParameter("MC"));
    else {
    String sAns = "";
    if (request.getParameter("MR1") != null) sAns += request.getParameter("MR1");
    if (request.getParameter("MR2") != null) sAns += request.getParameter("MR2");
    if (request.getParameter("MR3") != null) sAns += request.getParameter("MR3");
    eQuiz.checkAnswer(sAns);
    eQuiz.calAbility();
    // meet one of the stopping criteria?
    if (eQuiz.checkStopQuiz()) {
    %>
    <jsp:forward page="eQuiz_result.jsp"/>
    <%
    %>
    <html>
    <head>
    <title>QuizML Management System</title>
    </head>
    <frameset border="0" rows="30,*">
    <frame src="eQuiz_head.jsp" name="head" noresize scrolling="no">
    <frame src="eQuiz_detail.jsp" name="detail" scrolling="auto">
    </frameset>
    </html>

    Your JSP refers to the class:
    oracle/xml/parser/v2/XMLParseException
    ...which isn't in your webapps class path... you need to find the jar that contains the parser and drop it into WEB-INF/lib for your app, or the Tomcat lib directory.

  • How to force file download message box appear????

    I download file from oracle
    how to set response header to make download message box appear??????
    I just see lots of :
    ���?������ Y�Dl?��>��hn��?g�x~����?7���}��h`a�F��?P?!P��*�X��?/?U ��A?|?/??$�T=��t ��?^!i��f��/?]?�c��7?�UZ�Gz?��SbU��p���Q�T������?��e JyN�/�X^��w��/Bo�k�O��������^��$��?�������yg���C(??[�[+?��R�����p��?te@?��o��?M:D�_s#h�����H��g/?�nE"�PQI���A!��bE������?C`A�������?V��2�^��<�NK?[��k�k$??yJ>?sg-hm�AW(���S��?l[��[���� ��?dL4��6!�N��*���N?Q2?���JoP��>|�sb�_�^�_����~�r��X
    on the screen
    I am a chinese, happy new year everyone!

    and the file.size() is semicode, meaning there isnt a function for it. So you might end up with something like this
         response.setContentType( "application/zip" );
         String fileName = Globals.getAttachmentLocation() + readFile;
         response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
         BufferedInputStream bufferedInputStream = new BufferedInputStream( new FileInputStream( fileName ) );
         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
         int start = 0;
         int length = 1024;
         byte[] buff = new byte[length];
         while ( bufferedInputStream.read( buff, start, length ) != -1 ) {
              byteArrayOutputStream.write( buff, start, length );
         bufferedInputStream.close();
         response.setContentLength( byteArrayOutputStream.size() );
         response.getOutputStream().write( byteArrayOutputStream.toByteArray() );
         response.getOutputStream().flush();

  • Unwanted JSP files downloaded to desktop

    When I delete spam mail at yahoo.com, I get a JSP 400 X 600 icon downloaded on my desktop.
    Now, common internet address's (amazon.com) simply download a similiar icon on the desktop and when clicked on I don't get a internet page that I can use, but this: user/doughoover/desktop/amazon.com
    What can I turn off (or on) to stop the safari problem ?
    The yahoo mail may be a seperate problem.
    Thanks for the help. I searched the archives, but could not find a topic.

    Hi,
    We are also facing the same problem. We did little digging and found the relation with <jsp:include> tag.
    We have <jsp:include> tag with FLUSH property set to "TRUE".
    <jsp:include page="xyz.jsp" flush="true"/> and we have a Compression filter given by Oracle Support(that code is same as the one available in Orion (http://www.orionserver.com/tutorials/filters/5.html).
    If we enable Compression and try to access the page, we do get "File Download" dialog box, warning "some files can harm..." and with "open", "save", and "cancel" button.
    This should have given the executed page. We tried to work with removing compression, then it works. We tried to modify the "FLUSH" property to "FALSE", then it works fine even with Compression on.
    Since we need compression(basic requirement) and also we cannot change the code(TRUE to FALSE), can any one gives any idea what's happening with 9.0.3. Since the same code with compression is working fine in OC4J 1.0.2.2.
    Any help is greatly appreciated.
    Regards
    Arun

  • Jsp file download problem

    Hi,
    I am using following code in jsp.
    <%@ page session="true"%>
    <%@ page import="java.io.*" %>
    <%
    String fileName="test.txt";
    response.setContentType("application/txt");
    response.setHeader("Content-Disposition","attachment; filename="+fileName);
    try
    PrintWriter fw = response.getWriter();
    fw.write("param1");
    fw.write(",");
    fw.write("param2");
    fw.write(",");
    fw.write("param3");
    fw.write("\r\n");
    fw.flush();
    fw.close();
    catch(Exception e)
    %>
    <input type=button value="CONTINUE">
    The problem is flow does not go to CONTINUE button and it lost the control after response.setHeader("Content-Disposition","attachment; filename="+fileName);
    Do you have any idea what is the problem ?
    Thanks

    Hi
    I am trying to give user option so that he can download a file in his local machine.
    As you suggest use out object. I used the out object but i still have the same problem.
    After writig in a data.csv file, control does not go to the CONTINUE button.
    following is the sample code which i am using.
    <html>
    <body>
    <%
    String file="data.csv";
    //response.setContentType("application/vnd.ms-excel");
    response.setContentType("application/html");
    response.setHeader("Content-Disposition","attachment; filename="+file);
    try
    out.write("Test1");
    catch(Exception e)
    %>
    <div align="right">
    <input type=button value="CONTINUE">
    </div>
    </body>
    </html>
    do you have any suggestion to fix this problem?
    Kind Regards

  • File downloading problem: urgent

    hai ! I want to download a attached file from mail.
    If i use the following code i can get the file but
    i can't get the content of file.
    following is my code
    try
              part = multipart.getBodyPart(aid);
              contenttype=part.getContentType();
              fileName=part.getFileName();
              byte[] bytes=fileName.getBytes();
                 response.setContentType(contenttype);
                 response.addHeader("Content-Length",Integer.toString(bytes.length) );
                         response.addHeader("Content-Disposition", "attachment;filename="+fileName);
                        ServletOutputStream out=response.getOutputStream();
            out.write(bytes);
                        catch (MessagingException e) {
               e.printStackTrace();
              }

    The answer is in the JavaMail FAQ.

  • File download dialog box problem!

    Hi,
    How do you force file download message box to use specified file name instead of JSP or servlet name.
    I am using:
    // code in attachment.jsp
    <%
    response.setContentType(mimeType.trim());
    response.setHeader("Content-Disposition","attachment;filename=\""+attachmentViewBean.getAttachmentName()+ "\"");
    %>
    With the above code, browser first pop up file download dialog box informing
    'You are downloading the file:[attachment.jsp] from host. Would u like to open the file or save?'
    I want the file name that I had specified in setHeader("Content-disposition","attachment;filename=resume.doc") to appear(i.e. resume.doc) in above dialog box and not the servlet name.
    Any suggestions/tips on this?
    Your help would be greatly appreciated.
    Thanks,
    Yogesh

    For saving the document I have used -
    res.setHeader("Content-disposition", "attachment; filename="+ FileName );
    and it is working very fine, it saves the document with name specified in FileName
    For opening the file in browser without any prompt-
    res.setHeader("Content-disposition", "inline" );
    For setting the content type -
    try {
         if(FileType.equalsIgnoreCase("pdf")) contentType = "application/pdf";
         if(FileType.equalsIgnoreCase("doc")) contentType = "application/msword";
         if(FileType.equalsIgnoreCase("rtf")) contentType = "application/msword";
         if(FileType.equalsIgnoreCase("gif")) contentType = "image/gif";
         if(FileType.equalsIgnoreCase("jpg")) contentType = "image/jpeg";
         if(FileType.equalsIgnoreCase("html")) contentType = "text/html";
         if(FileType.equalsIgnoreCase("htm")) contentType = "text/html";
         if(contentType == null){
         contentType="text/plain";
         res.setContentType(contentType);
    } catch (Exception e){
              out.println("Exception while setting content type");
              out.println("Exception : " + e);
              return;
    Hope this helps

  • File Download not working for anchor tags

    Hello,
    I've encountered a bug with the 4.1.31 version of Tomcat. Apparently, when
    I use an anchor tag for a file, and I click on the link, it does not show the
    file download message "Do you want to open or save this file?" with the open
    and save options. Instead, it displays the file in the browser. I know you
    could normally save this information from the browser to a file, but I need it
    to show the download message because it's easier for users to save their
    file. I'm using Internet Explorer version 6, SP2. I've also tried setting
    the "Confirm open after download" check box for file types to no avail. It
    use to work in Tomcat 4.1.18.
    Any help would be appreciated.

    Can anyone pls. help me ? I tried all options from disbling firewall to uninstalling Bonjour.. But nothing works. Had I known that Apple makes such worst software I would never have bought iPhone !!!! Apple really *****!!!!!!!

  • Filename on file download from jsp

     

    This may help:
              ----- Original Message -----
              From: "Erik Lindquist" <[email protected]>
              Newsgroups: weblogic.developer.interest.jsp
              Sent: Wednesday, June 28, 2000 6:20 PM
              Subject: How to dynamically display images in JSPs
              > This took a little while to figure out so I thought I'd share. After
              > doing some research I was led to the following approach on how to load
              > images from an Oracle database into a JSP:
              >
              > The "main" JSP:
              >
              > <HTML>
              > <head>
              > <title>Image Test</title>
              > </head>
              > <body>
              > <center>
              > hello
              > <P>
              > <img border=0 src="getImage.jsp?filename=2cents.GIF">
              > <P>
              > <img border=0 src="getImage.jsp?filename=dollar.gif">
              > <P>
              > world
              > </body>
              > </HTML>
              >
              >
              > And this is the image getter:
              >
              > <% try {
              > response.setContentType("image/gif");
              > String filename = (String) request.getParameter("filename");
              > java.sql.Connection conn =
              > java.sql.DriverManager.getConnection("jdbc:weblogic:pool:orapool"); //
              > connect to db
              > java.sql.Statement stmt = conn.createStatement();
              > String sql = "select image from testimage where filename = '" +
              > filename + "'";
              > java.sql.ResultSet rs = stmt.executeQuery(sql);
              > if (rs.next()) {
              > byte [] image = rs.getBytes(1);
              > java.io.OutputStream os = response.getOutputStream();
              > os.write(image);
              > os.flush();
              > os.close();
              > }
              > conn.close();
              > }
              > catch (Exception x) { System.out.println(x); }
              > %>
              >
              >
              > The thing to note is that there are no <%@ page import="..." %> or <%@
              > page contentType="..." %> tags - just the single scriptlet. It
              > seems that for every "<%@" the weblogic compiler sees it puts
              > out.print("\r\n"); statements in the generated java source.(???) I
              > don't know much about how browsers work but I think that once it sees
              > flat ascii come at it it treats everything that follows as text/plain
              > which is incorrect for the binary stream that's being sent. Another
              > work around was to set out = null; but that's kind of ugly and might
              > produce server errors. The real fix is to write a bean to handle images
              > which I'll work on next (does anybody have any hints on how to do
              > that?)
              Cameron Purdy
              [email protected]
              http://www.tangosol.com
              WebLogic Consulting Available
              "Ramesh" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Hi,
              >
              > Even I could download the files with this technique, I couldn't open the
              file downloaded. It seems the file is getting currepted during tranfer.. Can
              u help me in this regard please?
              >
              > Thank u
              > Ramesh
              >
              > [email protected] (Anders B. Jensen) wrote:
              > >In an Web-application written in Java Server Pages it should be possible
              > >for the user to download data from the web-server. The data will never
              > >exist as a file on the web-server, only in the PrintWriter object, out.
              > >To force the Internet Explorer (IE) to show the download dialog window
              > >the Contenttype of the HTTP-header have been set to "html/transfer". The
              > >question is:
              > >
              > >Is it possible to set the filename appearing in the download dialog
              > >appearing on the client?
              > >
              > >
              > >Below is a listing of the source-code:
              > >
              > ><%@ page extends="com.beasys.portal.admin.PortalJspBase"%>
              > ><jsp:useBean id="download" scope="session" class="dk.lec.DownloadData" />
              > >
              > ><%
              > > String tmpstr;
              > > response.setContentType("html/transfer");
              > > out.clear();
              > > tmpstr=download.getStrbuffer().toString();
              > > out.println(tmpstr.trim());
              > >%>
              > >
              > >
              > >Anders B. Jensen
              > >Consultant, Research & Development
              > >LEC AS
              > >
              > >Remove the SPAMLESS to mail me.
              >
              

  • How to make file download in JSP ?

    Friends,
    i am using following code :
    // LISTING FILES IN DIR
            out.println("<br>");
            File dir = new File(dirName);
            String[] children = dir.list();
                 if (children == null)
            // Either dir does not exist or is not a directory
                 else
                    %>
                    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="68%" id="AutoNumber1">
                    <tr>
                        <td width="50%" align="center"><font face="Verdana">File</font></td>
                        <td width="50%" align="center"><font face="Verdana">Action</font></td>
                          </tr>   
                        <%
                        for (int i=0; i<children.length; i++)
                        // Get filename of file or directory
                        String filename = children;
    //out.println(filename);
    %>
    <tr>
    <td width="50%">
    <p align="center"><font face="Verdana"><%=filename %></font></td>
    <td width="50%">
    <p align="center"><font face="Verdana"><a href="<%= children[i %">">View</a></font></td>
    </tr>
    <%
    out.println("<br>");
    %>
    SInce i am not able to download file from link.
    link shows path correct but why its not working ??
    HELP ME.
    *i don't want to show real path( physical location of file) on file donwload link.*
    Example :
    *it will not allow to show like following :*
    *C:\project\webUpload\build\web\fuploads\file2.jpg*
    *it may allow like :*
    *\webUpload\fuploads\file2.jpg*
    Thanks</a>

    My friend you are getting it all wrong here...
    Here we would be taking help of a dedicated servlet to locate and download a file(which would be the output the respective concent of depeding of the fineName or fileId you send in).
    Please find some time and try to consider the below case...
    Say i have a Servlet which takes a Request of detailed filePath and would give output as file itself....
    and you prompt you give a link to that servlet from you JSP to download that file...
    Checkout the below Code snippets to get some idea
    DownloadPrompting.JSP:
    ==================
    <a href="FileServlet?fileName=C:\fileuploaded\image1.jpg" title="C:\fileuploaded\image1.jpg">Click Here to download Image1 JPEG File</a>
    <c:forEach var="fileName" items="${sessionScope.fileNames}">
       <a href="FileServlet?fileName=<c:uri value="${fileName}"/>" title="<c:out value="${fileName}"/>">Click Here to download</a>
    </c:forEach>
    -------------------------------------------------------------------------FileServlet.java
    ===========
    package com;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.BufferedOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.net.URLConnection
    public class FileServlet extends HttpServlet{
      private void processAction(HttpServletRequest request,HttpServletResponse response) throws Exception{
           // getting fileName which user is requesting for
           String fileName = request.getParameter("fileName").replace('\\','/');
           boolean exists = new File(fileName).exists();
           // Checking whether the file Exists or not      
           if(exists){
            FileInputStream input = null;
            BufferedOutputStream output = null; 
            int contentLength = 0;
            try{
                // Getting the Mime-Type
                String contentType = URLConnection.guessContentTypeFromName(fileName); 
                if(contentType == null)        
                   contentType = "application/octet-stream";
                input = new FileInputStream(fileName);
                contentLength = input.available();
                // Enables us to specify of what kind of content we are trying to download.
                response.setContentType(contentType);
                // Specifes How much amountof data we straming & trying to download
                response.setContentLength(contentLength);
                // Adding Content Disposition header so that it cud enable us to get OPEN/SAVE  after clicking on the link 
                response.setHeader("Content-Disposition","attachment;filename="+fileName+"\");
                // Initializing File Streaming Response via a Servlet
                output = new BufferedOutputStream(response.getOutputStream());
                // Placing each byte on to the stream after reading it from the file
                while ( contentLength-- > 0 ) {
                   output.write(input.read());
                 // Flushing the stream.         
                 output.flush();
              }catch(IOException e) {
                     System.err.println("Exception Occured:"+e.getMessage());
                 System.err.println("Exception Localized Message:"+e.getLocalizedMessage());
              } finally {
                   // Closing the INPUT stream 
                   if (input != null) {
                       try {
                          input.close();
                      } catch (IOException ie) {
                          System.err.println("Exception Occured:"+e.getMessage());
                             System.err.println("Exception Localized Message:"+e.getLocalizedMessage());                      
                   // Closing the OUTPUT stream 
                   if (output != null) {
                       try {
                          output.close();
                      } catch (IOException ie) {
                          System.err.println("Exception Occured:"+e.getMessage());
                             System.err.println("Exception Localized Message:"+e.getLocalizedMessage());                      
           }else{
             response.sendRedirect("/errorPage.html");
      public void doPost(HttpServletRequest request,HttpServletResponse response) throws Exception{       
            processAction(request,response); 
      public void doGet(HttpServletRequest request,HttpServletResponse response) throws Exception{
            processAction(request,response); 
    }And if you are thinking of hiding filepath & all...
    Here is a hint for you...
    Try to maintain a properties file which has a key value pairs of that something like.
    112345678=C:\\uploadfile\\image1.jpg
    122142637=C:\\uploadfile\\image2.jpg
    or create a Database table which which an autogenerated primany key with some Id and holds the complete filePath.
    and in this case you would access the file something like the one below from your jsp
    <a href="FileServlet?fileId=112345678" title="112345678">Click Here to download Image1 JPEG File</a>
    <c:forEach var="fileId" items="${sessionScope.fileNames}">
       <a href="FileServlet?fileId=<c:uri value="${fileId}"/>" title="<c:out value="${fileId}"/>">Click Here to download</a>
    </c:forEach>
    -------------------------------------------------------------------------and in the fileServlet you might have to change the below part to
    // getting fileName which user is requesting for
           String fileName = request.getParameter("fileName").replace('\\','/');to something like
    // getting fileName which user is requesting for
           String fileId = request.getParameter("fileId");
       /*Querying the database or reading the Properties file to findout the correspoding filePath associated with the fileId something like*/
        String fileName = ResourceDelegate.getInstance().getFile("fileId").replace('\\','/');
    NOTE:* The idea is similar to what my fellow poster is trying to explain you in all his posts.
    Hope that might help :)
    REGARDS,
    RaHuL

  • When i try to run my jsp i get "File Download Security Warning"

    Hi,
    I have created a jsp file which is called UpdateEmpDetails1.jsp
    This jsp file picks up the employee id of the employee and transfers it to the backend servlet called UpdateEmpDetails1.java. The backend servlet looks up the table stored in the database and pulls up all the information stored corresponding to the employee id.Then the servlet stores the information in a session object and forwards it to the UpdateEmpDetails2.jsp
    I display the information which has been forwarded by the servlet in the HTML fields of UpdateEmpDetails2.jsp.
    Here the manager can also update the information. When he clicks on submit, the second serlvet UpdateEmpDetails2.java which is linked to UpdateEmpDetails2.jsp picks up the updated information and updates the database. The servlet also displays the message "Your information has been updated". But here is the real problem
    The session variables are being transferred perfectly to the jsp file UpdateEmpDetails2.jsp.
    But when i make any changes to this file and click on submit I get File Download Security Warning. It Says:
    File Download Security Warning
    Do you want to save this file
    Name UpdateEmpDetails2
    Type UnknownFileType
    From LocalHost
    Then I get another file which says
    FileDownload
    Getting FIle Information
    UpdateEmpDetails2 from localhost
    Estimated time left
    Download to:
    Transfer rate:
    Close this dialog box when download is complete
    I am just simply not able to update the employee information in the database due to this message.

    this is what i am trying to do:
    my UpdateEmpDetails1.jsp is as follows:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional //EN">
    <html>
    <head>
    <title>UpdateEmpDetails1.jsp</title>
    <link REL=STYLESHEET
    HREF="JSP-Styles.css"
    TYPE="text/css">
    </head>
    <body BGCOLOR="lightyellow" text="black">
    <h2 align="left"><font color="black">Update Employee Details Page</font></h2>
    <form action="UpdateEmpDetails2" Method="Get">
    <h2 align="left">Please enter the Employee ID of the employee whose details you want to edit</h2>
    <table width=50% align="center">
    <tr><td>Employee ID : </td>
         <td><INPUT TYPE="TEXT" name="employeeid"><br></td></tr>
    <tr><td><center><INPUT TYPE="SUBMIT" VALUE="SUBMIT"></center></td></tr>
    <tr><td><center><INPUT TYPE="RESET" VALUE="RESET"></center></td></tr>
    </table>
    </form>
    </body>
    </html>
    my update EmpDetails1.java is as follows:
    package com.update;
    import com.database.*;
    import java.io.*;
    import java.sql.*;
    import javax.servlet.http.*;
    import javax.servlet.*;
    public class UpdateEmpDetails1 extends HttpServlet
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
              HttpSession session = request.getSession();
              String X = request.getParameter("employeeid");
              System.out.println("Employee ID:" + X);
              //Establishing the jdbc connection
              try
                   Database db = new Database();
                   Connection con = db.useConnection();
                   String query = "Select * from employees where employeeid=?";
                   PreparedStatement stat = con.prepareStatement(query);
                   System.out.println(stat);
                   stat.setString(1,X);
                   ResultSet rs = stat.executeQuery();
                   while(rs.next())
                        String A = rs.getString("employeeid");
                        String B = rs.getString("firstname");
                        String C = rs.getString("lastname");
                        String D = rs.getString("gender");
                        String E = rs.getString("dateofbirth");
                        String F = rs.getString("address");
                        String G = rs.getString("postalcode");
                        String H = rs.getString("phone");
                        String I = rs.getString("mobile");
                        String J = rs.getString("designation");
                        String K = rs.getString("joindate");
                        String L = rs.getString("leavedate");
                        String M = rs.getString("email");
                        String N = rs.getString("qualification");
                        String O = rs.getString("empstatus");
                             System.out.println("comparison successful");
                             session.setAttribute("employeeid",A);
                             session.setAttribute("firstname", B);
                             session.setAttribute("lastname", C);
                             session.setAttribute("gender", D);
                             session.setAttribute("dateofbirth", E);
                             session.setAttribute("address", F);
                             session.setAttribute("postalcode", G);
                             session.setAttribute("phone", H);
                             session.setAttribute("mobile", I);
                             session.setAttribute("designation", J);
                             session.setAttribute("joindate", K);
                             session.setAttribute("leavedate", L);
                             session.setAttribute("email", M);
                             session.setAttribute("qualification", N);
                             session.setAttribute("empstatus", O);
                             String url="/UpdateEmpDetails2.jsp";
                             RequestDispatcher dis = request.getRequestDispatcher("/UpdateEmpDetails2.jsp");
                             System.out.println("Dispatching" + dis);
                             dis.forward(request, response);
              catch(Exception e)
                   System.out.println(e);
    my UpdateEmpDetails2.jsp is as follows:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>UpdateEmpDetails2.jsp</title>
    <link REL=STYLESHEET
    HREF="JSP-Styles.css"
    TYPE="text/css">
    </head>
    <body BGCOLOR="lightblue" text="black">
    <h1 align="center"><font color="black">Update Employee Details Page</font></h1>
    <form action="UpdateEmpDetails2" Method="Get">
    <table width=50% align="center">
    <tr><td>EMPLOYEE ID:</td>
         <td><INPUT TYPE = "HIDDEN" name="employeeid" value=<%=session.getAttribute("employeeid")%> ></td></tr>
    <tr><td>FIRST NAME :</td>
         <td><INPUT TYPE = "TEXT" name="firstname" value=<%=session.getAttribute("firstname")%> ></td></tr>
    <tr><td>LAST NAME :</td>
         <td><INPUT TYPE = "TEXT" name="lastname" value=<%=session.getAttribute("lastname")%> ><br></td></tr>
    <tr><td>GENDER :</td>
         <td><INPUT TYPE = "TEXT" name="gender" value=<%=session.getAttribute("gender")%> ><br></td></tr>
    <tr><td>DATE OF BIRTH (IN MM/DD/YYYY FORMAT) :</td>
         <td><INPUT TYPE = "TEXT" name="dateofbirth" value=<%=session.getAttribute("dateofbirth")%> ><br></td><tr>
    <tr><td>ADDRESS :</td>
         <td><INPUT TYPE = "TEXT" name="address" value=<%=session.getAttribute("address")%> ><br></td></tr>
    <tr><td>POSTALCODE:</td>
         <td><INPUT TYPE = "TEXT" name="postalcode" value=<%=session.getAttribute("postalcode")%>><br></td></tr>
    <tr><td>PHONE:</td>
         <td><INPUT TYPE = "TEXT" name="phone" value=<%=session.getAttribute("phone")%> ><br></td></tr>
    <tr><td>MOBILE:</td>
         <td><INPUT TYPE = "TEXT" name="mobile" value=<%=session.getAttribute("mobile")%> ><br></td></tr>
    <tr><td>DESIGNATION : </td>
    <td><INPUT TYPE="TEXT" name="designation" value=<%=session.getAttribute("designation")%> > <br></td></tr>
    <tr><td>JOIN DATE:</td>
         <td><INPUT TYPE = "TEXT" name="joindate" value=<%=session.getAttribute("joindate")%> ><br></td></tr>
    <tr><td>LEAVE DATE:</td>
         <td><INPUT TYPE = "TEXT" name="leavedate" value=<%=session.getAttribute("leavedate")%> > <br></td></tr>
    <tr><td>EMPLOYEE EMAIL:</td>
         <td><INPUT TYPE = "TEXT" name="email" value=<%=session.getAttribute("email")%> ><br></td></tr>
    <tr><td>EMPLOYEE QUALIFICATION:</td>
         <td><INPUT TYPE = "TEXT" name="qualification" value=<%=session.getAttribute("qualification")%> > <br></td></tr>
    <tr><td>EMPLOYEE STATUS:</td>
         <td><INPUT TYPE = "TEXT" name="empstatus" value=<%=session.getAttribute("empstatus")%> > <br></td></tr>
    <tr><td><center><INPUT TYPE="SUBMIT" VALUE="SUBMIT"></center></td></tr>
    <tr><td><center><INPUT TYPE="RESET" VALUE="RESET"></center></td></tr>
    </table>
    </form>
    </body>
    </html>
    my UpdateEmpDetails2.java is as follows:
    package com.update;
    import java.io.*;
    import java.sql.*;
    import javax.servlet.http.*;
    import javax.servlet.*;
    import com.database.*;
    public class UpdateEmpDetails2 extends HttpServlet
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
              PrintWriter out = response.getWriter();
              response.setContentType("texthtml");
              String A = request.getParameter("employeeid");
              out.println(A);
              String B = request.getParameter("firstname");
              out.println(B);
              String C = request.getParameter("lastname");
              out.println(C);
              String D = request.getParameter("gender");
              out.println(D);
              String E = request.getParameter("dateofbirth");
              out.println(E);
              String F = request.getParameter("address");
              out.println(F);
              String G = request.getParameter("postalcode");
              out.println(G);
              String H = request.getParameter("phone");
              out.println(H);
              String I = request.getParameter("mobile");
              out.println(I);
              String J = request.getParameter("designation");
              out.println(J);
              String K = request.getParameter("joindate");
              out.println(K);
              String L = request.getParameter("leavedate");
              out.println(L);
              String M = request.getParameter("email");
              out.println(M);
              String N = request.getParameter("qualification");
              out.println(N);
              String O = request.getParameter("empstatus");
              out.println(O);
              try
              Database db = new Database();
              Connection con = db.useConnection();
              String query= "update employees set employeeid=?,firstname=?,lastname=?,gender=?,dateofbirth=?,address=?,postalcode=?,phone=?,mobile=?,designation=?,joindate=?,leavedate=?,email=?,qualification=? where employeeid=?";
              PreparedStatement stat = con.prepareStatement(query);
              stat.setString(1, B);
              stat.setString(2, C);
              stat.setString(3, D);
              stat.setString(4, E);
              stat.setString(5, F);
              stat.setString(6, G);
              stat.setString(7, H);
              stat.setString(8, I);
              stat.setString(9, J);
              stat.setString(10, K);
              stat.setString(11, L);
              stat.setString(12, M);
              stat.setString(13, N);
              stat.setString(14, O);
              stat.setString(15, A);
              System.out.println(stat);
              int i = stat.executeUpdate();
              if (i!= 0)
              System.out.println("The record has been updated");
              else
                   System.out.println("Sorry ! failure");
              ResultSet rs = stat.executeQuery("select * from employees");
              System.out.println(rs);
              while(rs.next())
                   out.print("<table border='1'>");
                   out.println(rs.getString(1) + "<br>");
                   out.println(rs.getString(2) + "<br>");
                   out.println(rs.getString(3) + "<br>");
                   out.println(rs.getString(4) + "<br>");
                   out.println(rs.getString(5) + "<br>");
                   out.println(rs.getString(6) + "<br>");
                   out.println(rs.getString(7) + "<br>");
                   out.println(rs.getString(8) + "<br>");
                   out.println(rs.getString(9) + "<br>");
                   out.println(rs.getString(10) + "<br>");
                   out.println(rs.getString(11) + "<br>");
                   out.println(rs.getString(12) + "<br>");
                   out.println(rs.getString(13) + "<br>");
                   out.println(rs.getString(14) + "<br>");
                   out.println(rs.getString(15) + "<br>");
                   out.print("<br>");
              catch (Exception e)
                   System.out.println(e);
                   e.printStackTrace();
    Now as soon as i click on the submit button of the first jsp i get "File Download security warning message"
    I am new to jsp and i am not able to troubleshoot this

  • Creating a file download link on jsp

    I have the following on my jsp. The code worked fine until I tried to use it in a new html design page.
    <code>
    //page name is index.jsp
    try //DISPLAY THE CONTENTS OF THE DATA DIRECTORY
    File dirname = new File(PATH); // create an instance of the File class
    if (dirname.exists()&&dirname.isDirectory())//check to see if File class dirname exists and is valid
    String [] allfiles = dirname.list();//create an array of files in the dirname File class
              for (int i=0; i< allfiles.length; i+=2)//loop through allfiles[] and print out file links
    out.println("<br><table border='1' cellspacing='1' width='99%'>");
                   out.println("<tr><td width='50%' class='pageFont'><input type='checkbox' name='cb' value='"+allfiles[i]+"'>"+allfiles[i]+"      ");
    %>
    <a class="a" href="index.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a></td>
    <% if(i+1 < allfiles.length)//PRINTS OUT THE SECOND TD SO THAT WE HAVE 2 COLUMNS OF LINKS
    out.println("<td width='50%' class='pageFont'><input type='checkbox' name='cb' value='"+allfiles[i+1]+"'>"+allfiles[i+1]+"      ");
    %>
    <a class="a" href="index.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a></td></tr>
    <%
    out.println("</form></font></table>");
    catch (IOException excep)
         out.println("An IO exception has occured.");
    </code>
    Then when clicked this code is run:
    <code>
    try{
    //CHECK TO SEE IF THE FILE HAS BEEN CLICKED TO DOWNLOAD SINGLE FILE
    if (request.getParameter("downfile") != null)
    String filePath = request.getParameter("downfile");
    File f = new File(filePath);//CREATE AN INSTANCE OF THE FILE CLASS AND POINT IT TO THE LOCATION OF THE DIRECTORY CONTAINING THE FILES
    if (f.exists() && f.canRead())
    response.setContentType ("application/octet-stream");
    response.setHeader ("Content-Disposition", "attachment;filename=\""+f.getName()+"\"");
    response.setContentLength((int) f.length());
    BufferedInputStream fileInputStream = new BufferedInputStream(new FileInputStream(f));
    int i;
    out.clearBuffer();
    while ((i = fileInputStream.read()) != -1) out.write(i);
    fileInputStream.close();
    out.flush();
    </code>
    When I click on this link I get the download dialog box. If I open it I get the following open up in notepad(the files I am trying to give download links are .txt files)
    Below is what is displayed in notepad ALL on 1 line:
    <html>
    <head>
    <LINK rel="stylesheet" ty
    That is displayed in all of the links that I click on. It is the first few lines of html code for index.jsp.
    I know this code is probably not a good way of doing what I need but I got it to work fine until the change.
    I am sure there is an easier way to code the download link without resubmitting the page.
    Thanks in advance!!

    Well all was fine with this jsp until I moved it to ApacheJServ. Now the problem has resurfaced(although it is a little different now)
    I had moved the following code to the top of my page:
    //CHECK TO SEE IF EITHER DOWNFILE OR ZIPFILE VARIABLE EXIST, AND IF THEY DO SET CONTENT TYPE BEFORE SENDING ANY HTML CODE TO THE BROWSER
    try{
    //CHECK TO SEE IF THE FILE HAS BEEN CLICKED TO DOWNLOAD SINGLE FILE
        if (request.getParameter("downfile") != null)
                String filePath = request.getParameter("downfile");
                File f = new File(filePath);//CREATE AN INSTANCE OF THE FILE CLASS AND POINT IT TO THE LOCATION OF THE DIRECTORY CONTAINING THE FILES
                    if (f.exists() && f.canRead())
                        response.setContentType ("application/octet-stream");
                        response.setHeader ("Content-Disposition", "attachment;filename=\""+f.getName()+"\"");
                        response.setContentLength((int) f.length());
                        BufferedInputStream fileInputStream = new BufferedInputStream(new FileInputStream(f));
                        int i;
                        out.clearBuffer();
                        while ((i = fileInputStream.read()) != -1) out.write(i);
                            fileInputStream.close();
                            out.flush();
                            response.flushBuffer();
    catch (Exception e){}
    //This is where the java code ends and the javascript/html code begins.Then further into the page I create the file download links like so:
                            <a class="a" href="main.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a>I know this isnt a secure way of doing this but I am on a intranet.
    The problem I am having now is that when I click on one of the links and download the file and then open it, I get the contents of the file plus concatenated to the end of it is the first few HTML lines of the actual jsp that I downloaded the file from. Before I was just getting the first few lines of html from the jsp, not the actual contents of the downloaded file.
    This is an example of what I am getting:
    This is the contents of the file that I downloaded.//This is where the file contents ends.
    <html>
    <head>
    <LINK rel="stylesheet" type="text/css" href="default.css">
    <script language="JavaScript1.2">
    //function that allows user to select all checkboxes
    function doIt(v)
    for(var i=0;i<document.form1.cb.length;i++)
       document.form1.cb.checked=eval(v);
    function swap(imageName,image)
    imageName.src = "templateImages/"+image;
    function imageOver(imageSrc, imageName)
         changeImage = new Image();
         changeImage.src = imageSrc;
         document.images[imageName].src = changeImage.src;
    var hide = true;
    function hideShow( ) /
    Any morre ideas?
    TIA!
    BTW, I went to ApacheJServ because they wont let me use tomcat :(

  • JSF error message: Automatic prompting for file download

    This is a weird problem. I have a JSF application wherin I popup a new window on a submit button.
    The window opens a test.jsf page that redirects the output to a servlet1.
    Servlet then based on some parameters does a sendRedirectI() to different servlets out of context.
    Now the issue is that when the output is redirected to out of context servlet, that returns a file download.
    If in IE browser, if one does not do a setting of "Automatic prompting for file download", this window that I had opened on submit buttton vanishes in a jiffy. If the IE setting is done, it shows the file download correctly.
    I would want to show the user some kind of message by which he/she understands that this IE setting has to be done.
    I have tried several ways:
    1. Javascript: window.onbeforeunload on the test.jsf so that when the window unloads i can show some message. But since test.jsf forwards to servlet1, the html page generated does not show my script.
    2. I also tried checking if some windows registry can help me understand the setting.
    3. I tried writing in response object the javascript and then redirecting it to servlet out of context. But I guess sendRedirect() does a new request, so this did not help.
    Can anyone help? I am not sure if I am able to explain my problem correctly.
    Yani

    Here is the result.I used your code and it worked fine with IE setting Enabled. But when I tried to access the download servlet after opening a new window, it doesnt download the file.

Maybe you are looking for

  • How to download file to local system when report is run in background?

    Hello all, Can anybody tell me how can we donwload file into local machin when the program is running in background? thanks

  • My Macbook Pro has become super slow after upgrading to 10.9.2. can anyone help please?

    My Macbook pro has slowed down drastically after upgrading to 10.9.2. It has become so slow that i can hardly use it. I did an etrcheck Hardware Information:           MacBook Pro (13-inch, Mid 2012)           MacBook Pro - model: MacBookPro9,2     

  • Dynamic SELECT with FOR ALL ENTRIES IN: take 2

    Hello Xperts, we are now having a bit of new trouble with the following SELECT ... special thanks to Raul and Suhas for their previous contributions. FIELD-SYMBOLS:         <itab1>      TYPE standard table.   ASSIGN ATTR_T_I->* TO <itab1>.     select

  • Indexes created in database

    Hi, on FSCM 91, on Win 2008, Tools 8.52, DB Oracle 11g. If an index is created not in Application designer (but in for example in SQLPLUS) would it be used by PeopleSoft when browsing or running a batch by Process Scheduler ? In other words the index

  • Solaris 10 apache does not auto start at boot

    Hello I have installed solaris 10 on a sun machine and later added the security toolkit 4.2. I need the apache server running which I have to do manually once the system reboots. Later on further advise I made apache as Identity Manager service throu