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 9162217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:09:30+00:00 2026-06-17T14:09:30+00:00

I’m always getting this warning in Jetty 9 when accessing this Servlet (with GET

  • 0

I’m always getting this warning in Jetty 9 when accessing this Servlet (with GET or POST):

package de.swt1321.servlet;

import java.util.ArrayList;

import java.io.OutputStream;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ServletTest extends HttpServlet {
    private static final int UNPROCESSABLE_ENTITY = 422;
    private static final java.nio.charset.Charset UTF8 = java.nio.charset.Charset.forName("UTF8");
    private ArrayList<Person> persons = new ArrayList<Person>(); 
    @Override
    public void doGet(HttpServletRequest req,
                          HttpServletResponse res) throws ServletException, IOException
    {
        byte [] HTML = genHTML();
        res.setStatus(HttpServletResponse.SC_OK);
        res.setHeader("content-type","text/html;charset=utf8");
        res.setIntHeader("content-length",HTML.length);
        OutputStream os = res.getOutputStream();
        os.write(HTML);
        os.flush();
    }

    @Override
    public void doPost(HttpServletRequest req,
                        HttpServletResponse res) throws ServletException, IOException
    {
        String firstName = req.getParameter("firstName");
        String lastName = req.getParameter("lastName");
        if(firstName == null || lastName == null) {
            res.setStatus(UNPROCESSABLE_ENTITY);
            return;
        }
        persons.add(new Person(req.getParameter("firstName"),req.getParameter("lastName")));
        byte[] HTML = genHTML();
        res.setStatus(HttpServletResponse.SC_OK);
        res.setHeader("content-type","text/html;charset=utf8");
        res.setIntHeader("content-length",HTML.length);
        OutputStream os = res.getOutputStream();
        os.write(HTML);
        os.flush();
    }

    private byte[] genHTML() {
        String HTMLString = "<!DOCTYPE html>"+
            "<html>"+
            "<head>" +
            "<title>Hello World!</title>"+
            "<style>" +
            "table,th,tr { border: 1px solid black;}"+
            "</style>" +
            "</head>"+
            "<body><table><tr><th>First Name</th><th>Last Name</th></tr>";
        for(Person person : persons) {
            HTMLString += "<tr><td>"+person.firstName+"</td><td>"+person.lastName+"</td></tr>";
        }
        HTMLString += "</table>"+
            "<form name='input' action='/ServletTest-1.0.0/hello' method='post'>"+
            "<input type='text' name='firstName'/>"+
            "<input type='text' name='lastName'/>" +
            "<input type='submit' value='Send me!'/>"+
            "</form>" +
            "</body>" +
            "</html>";
        return HTMLString.getBytes(UTF8);
    }

    private static class Person {
        public String firstName;
        public String lastName;
        public Person(String firstName, String lastName) {
            this.firstName = firstName;
            this.lastName = lastName;
        }
    }
}

web.xml:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0"> 

    <servlet>
        <servlet-name>HelloWorldServlet</servlet-name>
        <display-name>Hello World App</display-name>
        <load-on-startup>1</load-on-startup>
        <servlet-class>de.swt1321.servlet.ServletTest</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>HelloWorldServlet</servlet-name>
        <url-pattern>/hello</url-pattern>
    </servlet-mapping>

</web-app>

Is this something I should worry about? If yes, how do I fix this? What does this even mean anyway?

  • 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-06-17T14:09:31+00:00Added an answer on June 17, 2026 at 2:09 pm

    This is caused because you are flushing the Output stream.
    Simply remove the op.flush(); and let Jetty handle it

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.