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

  • SEARCH
  • Home
  • 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 4025000
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:47:31+00:00 2026-05-20T10:47:31+00:00

Good day! I encountered the following error upon running my JSP program. java.lang.IllegalStateException: PWC3991:

  • 0

Good day!

I encountered the following error upon running my JSP program.

java.lang.IllegalStateException: PWC3991: getOutputStream() has already been called for this response

It seems like the html file inside my JSP doesn’t work.
My code is as follows:

<%@page import  = "java.util.*"%>
<%@page import  = "javax.servlet.*"%>
<%@page import  = "javax.servlet.http.*"%>
<%@page import= "session.*" %>


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <%
            Item item = (Item) request.getAttribute("invenItem");

            if (item != null) {
                out.println("<html><title>Inventory Item</title>");
                out.println("<body><h1>Inventory Item Details:</h1>");
                out.println("Stock ID  : " + item.getStockID() + "<br/>");
                out.println("Name      : " + item.getItemName() + "<br/>");
                out.println("Unit Price: " + item.getUnitPrice() + "<br/>");
                out.println("On Stock  : " + item.getOnStock() + "<br/>");
                out.println("</body>");
                out.println("</html>");
            } else {
                RequestDispatcher rd = request.getRequestDispatcher("DataForm.html"); //NOT WORKING
                rd.include(request, response);

                out.println("<br>Item not found...<br>");

                rd = request.getRequestDispatcher("ItemEntry.html"); //NOT WORKING
                rd.include(request, response);
            }
            %>
        </body>
    </html>

My html Files are located inside the folder WEB-INF. How can I make it work? DO i need to import it also? Thank you.

  • 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-20T10:47:32+00:00Added an answer on May 20, 2026 at 10:47 am

    Don’t use scriptlets (those <% %> things). JSP is a template technology for HTML. You don’t need all those nasty out.println() things for HTML. Just write HTML plain in JSP.

    So, instead of

    <%
        out.println("<html><title>Inventory Item</title>");
    %>
    

    just do

    <html><title>Inventory Item</title>
    

    (note that this results in invalid HTML, there should be only one <html> tag in a HTML page and only one <title> in the <head>, but that’s a different problem, the w3 HTML validator should give a lot of hints and answers, also get yourself through some HTML tutorials)


    JSP offers EL (Expression Language, those ${ } things) to access backend data, i.e. the data which is present as attribute in page, request, session and application scopes. It can be accessed using the attribute name.

    So, instead of

    <%
        Item item = (Item) request.getAttribute("invenItem");
    %>
    

    use

    ${invenItem}
    

    and instead of

    <%
        out.println("Stock ID  : " + item.getStockID() + "<br/>");
    %>
    

    use

    Stock ID: ${invenItem.stockID}<br/>
    

    JSP also offers taglibs like JSTL to control the page flow and output.

    So, instead of

    <%
        if (item != null) {
    
        } else {
    
        }
    %>
    

    use

    <c:choose>
        <c:when test="${invenItem != null}">
    
        </c:when>
        <c:otherwise>
    
        </c:otherwise>
    </c:choose>
    

    JSP also offers <jsp:include> tag to include page fragments.

    So, instead of

    <%
        RequestDispatcher rd = request.getRequestDispatcher("DataForm.html"); //NOT WORKING
        rd.include(request, response);
    %>
    

    use

    <jsp:include page="/WEB-INF/DataForm.jsp" />
    

    (and rename it to .jsp)

    And the exception will disappear.


    See also:

    • JSP tag info page
    • How to avoid Java code in JSP files?
    • Java web development, what skills do I need?

    Unrelated to the concrete problem, almost all of the links in this answer was already (in)directly given to you in your previous questions. Take them serious. To become a great programmer (as you ever stated in a question/comment), take some time to get yourself through those links (and the links in the links).

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

Sidebar

Related Questions

I was wondering if anyone has a good solution to a problem I've encountered
Good day all I wrote the following method: private void RegisterEvent(object targetObject, string eventName,
Good day! I use strategy to handle 404 errors like this: Error handling for
Good day, We just converted our web application .NET 1.1 to .NET 2.0. We
Good day, I'm having a problem with asp.net 2.0 viewstate. Basically, I want to
Good day, In visual studio 2005, when I drop a webcontrol in the designer,
I've spent a good part of the day searching, writing and finally scrapping a
ISQL-SE 4.10.DD6 (DOS 6.22): My app has the following SQL script (CODE REVIEW) which
Good day. I got a problem about the attribute of ref for my XSD
Good day. When i try to run the example from MSDN. But it failed

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.