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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:21:57+00:00 2026-05-16T15:21:57+00:00

What I am trying to do is to run a simple Servlet from a

  • 0

What I am trying to do is to run a simple Servlet from a java class.

Actually I have a Servlet1 that is started from an html code through a post action. That servlet outputs some other html page but also calls a Java class. What I try to do now is to start a Servlet2 that outputs html code from that java class. I did:

URL url = new URL("http://localhost:8080/WebApplication/Servlet2");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);

but the servlet2 is not opened in the browser even though i output in the proccessRequest method some html code.

Isn’t the Servlet2 getting a request? Where i’m going wrong or what i’m missing?

Kind regards, Adriana

  • 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-16T15:21:58+00:00Added an answer on May 16, 2026 at 3:21 pm

    Your question is vague and ambiguous and the functional requirement is unclear, so I can’t give a detailed answer how to achieve the particular functional requirement.

    But at least, the following phrase is a bit odd:

    but the servlet2 is not opened in the browser

    That particular code will in no way open the mentioned URL in some webbrowser. That Java code does in no way interact with any of the installed webbrowsers at the local machine. If your sole intent is to open the particular URL in the local machine’s default webbrowser (e.g. Firefox, MSIE, etc), then you rather need Desktop#browse(). E.g.

    Desktop.getDesktop().browse(new URI("http://google.com"));
    

    If that’s also not what you’re looking for, then I don’t know. All I can suggest is to get yourself through this topic to learn how to fire and handle HTTP requests programmatically using Java code. Probably you’re monitoring the webserver’s log files to see if the servlet is been requested. This will only happen when URLConnection is actually firing the request. Only calling openConnection() won’t do that.

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

Sidebar

Related Questions

I am trying to run the following simple code, public abstract class Shape{ abstract
I am trying to run simple code from examples: require.paths.unshift('/etc/npm'); // path to modules
I've been trying to run a simple applet that I created from the command
I am new to Tomcat, and trying to run a simple HelloWorld servlet. I
I'm trying to run a simple query with PDO in PHP. The code is
I am trying to run a simple linear regression (using rpy2 from Python) and
I am trying to run this dreadfully simple command in Bash java -cp nasa-top-secret.jar
Trying to run a simple svn list svn+ssh://... from within jenkins on os X,
I'm trying to run a simple query with an ORM that is built on
I'm trying run a simple Java/MySQL web app tutorial in NetBeans. I am able

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.