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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:51:50+00:00 2026-05-25T18:51:50+00:00

In the server side code, I am writing a string (which gets written on

  • 0

In the server side code, I am writing a string (which gets written on a browser page) using OutputStreamWriter. This gets written in a new window. I need to be able to write this in the same window.

The class extends HttpServlet and following is the structure of the code:

void foo(HttpServletResponse response...) {
...
    OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream());
    response.reset();
    response.setContentType("text/html");
    out.write("Hello World!"); // Or some html string
    out.flush();  
    out.close();
}    
  • 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-25T18:51:50+00:00Added an answer on May 25, 2026 at 6:51 pm

    The server side (the servlet) don’t and can’t open a new window (fortunately, otherwise spamming the client with popups would be tremendously easy…). The client (the browser) is the only who can open a new window. Most likely you’ve used one of the following constructs in HTML or JavaScript which will show the result in a new window:

    <form action="servleturl" target="_blank">
    

    or

    <a href="servleturl" target="_blank">
    

    or

    <script>window.open('servleturl', 'windowname');</script>
    

    You need to remove the target="_blank" to get the response in the current window, or in case you’re using JavaScript, to use window.location = 'servleturl'; instead.


    Unrelated to the concrete question, emitting HTML in a servlet is a poor practice. Use JSP instead.

    See also:

    • Our servlets wiki page
    • Our JSP wiki page
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to ask in which phase of Control Execution Lifecycle is the Server-Side-Code
I am validating a zip code using Javascript that is generated server-side, and injected
ASP.NET server-side controls postback to their own page. This makes cases where you want
Developing server side code i finally got my eyes X-crossed trying to write -
For a particular project I have, no server side code is allowed. How can
I'm thinking to add some code on the server side in asp.net, to verify
I'm writing server-side programs in PHP for an iPhone app. And I have no
I am writing a markdown compiler in Erlang for server-side use. Because it will
I'm writing a php forms class with client and server side validation. I'm having
I'm currently writing a project in Python which has a client and a server

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.