Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6876337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:27:53+00:00 2026-05-27T04:27:53+00:00

I am getting an error in my java servlet. The servlet fills the fields

  • 0

I am getting an error in my java servlet. The servlet fills the fields of an existing pdf. The page pulls up an alert asking “Do you want to open or save this file?” So if I press “Open” or “Save” it works fine, and does the correct thing. But…. if I press “Cancel”, nothing pops up, and I get this error:

com.evermind.server.http.HttpIOException: An existing connection was forcibly closed by the remote host

I am not sure why or where this error is coming about, but it says that the error is happening on this line:

stamp.close();

If more code snippets are needed, please let me know. I just didnt want to paste everything in here, because I dont exactly know where it is happening. Thanks in advance.

EDIT

Here is the majority of my relevant code:

    try {      

conn = ((DataSource) new InitialContext().lookup(dSource)).getConnection();

    stmt = conn.prepareStatement("....");    

rs = stmt.executeQuery();

if (rs.next()) {
    ....
}

    stmt = conn.prepareStatement("....");

    rs = stmt.executeQuery();


if (rs.next()) {      
    ....
}  

if (isTempVerification) {

     final String tempFile = "TemporaryVerification.pdf";

     try {

         response.setHeader(contentDisposition, "attachment; filename=" + tempFile);
         reader = new PdfReader(this.getServletContext().getResource("/pdf/" + tempFile));
         stamp = new PdfStamper(reader, response.getOutputStream());
         form = stamp.getAcroFields();
         form.setField("date", current);
         form.setField("reply_line", replyLine);
         form.setField("first_middle_last", fmlName);
         form.setField("term_year_1", termYear + ".");
         form.setField("census_date", termCensus);
         form.setField("term_year_2", termYear + ".");

         //stamp.setFormFlattening(true);
         stamp.close();

     } catch (IOException e) {
         errorFound = true;
         e.printStackTrace(System.err);
     } catch (DocumentException e) {
         errorFound = true;
         e.printStackTrace(System.err);
     }

} else {

    final String officialFile = "OfficialVerification.pdf";

    try {

        response.setHeader(contentDisposition, "attachment; filename=" + officialFile);    
        reader = new PdfReader(this.getServletContext().getResource("/pdf/" + officialFile));
        stamp = new PdfStamper(reader, response.getOutputStream());
        form = stamp.getAcroFields();
        form.setField("date", current);
        form.setField("reply_line", replyLine);
        form.setField("first_middle_last", fmlName);
        form.setField("status", studentStatus);
        form.setField("hr", hoursTaken);
        form.setField("term_year", termYear);
        form.setField("start_end_date", termStart + " - " + termEnd);

        //stamp.setFormFlattening(true);
        stamp.close();

    } catch (IOException e) {
        errorFound = true;
        e.printStackTrace(System.err);
    } catch (DocumentException e) {
        errorFound = true;
        e.printStackTrace(System.err);
    }

}

} catch (NamingException e) {
    e.printStackTrace(System.err);
} catch (SQLException e){
    e.printStackTrace(System.err);
} finally {if (stmt != null) try {stmt.close();
    } catch (SQLException e){
            e.printStackTrace(System.err);
    } if (rs != null) try {rs.close();
            } catch (SQLException e){
                e.printStackTrace(System.err);}
   try {
    if (conn != null && !conn.isClosed()) {
      conn.close();
    }
   } catch (SQLException e) {
    e.printStackTrace(System.err);
   } 
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:27:53+00:00Added an answer on May 27, 2026 at 4:27 am

    when u make the stamp.close() call, the output stream is also flushed. since you set the response headers before stamp.close(), the response headers are also written to the client. consequently, this causes the file download dialog to appear on the client. when the client clicks ‘cancel’, the http connection is terminated.

    your servlets need to maintain the http connection throughout its execution as it will be writing output to the response output stream. if the http connection is terminated before the response has been committed, you will get the exception that you are seeing now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why do I keep getting this error: javax.servlet.ServletException: java.sql.SQLException: [Oracle][ODBC][Ora]ORA-00904: PURCHASE_PRICE: invalid identifier As
I'm trying to build a java application with gcj but getting the error below.
I have done simple java app for blackberry, while building am getting following error.
I'm getting a NoSuchMethodError error when running my Java program. What's wrong and how
I'm getting the following error when I try to run a simple Java JDBC
I'm getting a java.awt.FontFormatException: Unrecognised Font Format error, and I believe this has been
This is my JSP page's taglib directive: <%@ taglib uri=http://java.sun.com/jsp/jstl/core prefix=c %> I'm getting
I am getting the following error when i tried to run my Java REST
Hello all I'm getting this very strange error: java.lang.NoSuchMethodError: org.hibernate.SessionFactory.getCurrentSession()Lor g/hibernate/classic/Session; at org.cometd.hibernate.util.HibernateUtil.getSessionFactory(HibernateUt il.java:29)
@Autowiring is not working on fields and am getting: Error: SEVERE: StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException: Error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.