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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:38:19+00:00 2026-06-12T16:38:19+00:00

The following code exist on http://docs.oracle.com/javase/tutorial/networking/urls/readingWriting.html Which is the oracle tutorial website. My problem

  • 0

The following code exist on

http://docs.oracle.com/javase/tutorial/networking/urls/readingWriting.html

Which is the oracle tutorial website.

My problem is with understanding the servlet. As you can see in documentation at the bottom of the page it says:

If your ReverseServlet is located at http://example.com/servlet/ReverseServlet, then when you run the Reverse program using

http://example.com/servlet/ReverseServlet “Reverse Me”

To run this example I tested my program with this link

http://docs.oracle.com/javase/tutorial/networking/urls/examples/ReverseServlet.java “Reverse Me”

and I got this error:

Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http://docs.oracle.com/javase/tutorial/networking/urls/examples/ReverseServlet.java
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
    at DemoURL.main(DemoURL.java:28)

Is it the place that my ReverseServlet is located or I’m totally wrong. If this not the correct way how can I run this program to check this example in tutorial?

Here is the code I have changed the class name:

    import java.io.*;
    import java.net.*;
    public class DemoURL {
        public static void main(String[] args) throws Exception {

            if (args.length != 2) {
                System.err.println("Usage:  java Reverse "
                    + "http://<location of your servlet/script>"
                    + " string_to_reverse");
                System.exit(1);
            }

            String stringToReverse = URLEncoder.encode(args[1], "UTF-8");

            URL url = new URL(args[0]);
            URLConnection connection = url.openConnection();
            connection.setDoOutput(true);

            OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());

            out.write("string=" + stringToReverse);
            out.close();



            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String decodedString;
            while ((decodedString = in.readLine()) != null) {
                System.out.println(decodedString);
            }
            in.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-06-12T16:38:21+00:00Added an answer on June 12, 2026 at 4:38 pm

    The url you use http://docs.oracle.com/javase/tutorial/networking/urls/examples/ReverseServlet.java does not contain a running version of the reverse servlet, just the source.

    If you want to run the servlet you need to compile it and deploy the servlet yourself in a servlet container of your choice such as Tomcat, Jetty or similar. The servlet container handles accepting the request,parsing it and passing the request to the servlet.

    Here is a description of how to (relatively) easily run a servlet Fastest way to deploy a Java servlet.

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

Sidebar

Related Questions

I'm using the following code for practising, http://docs.oracle.com/javase/tutorial/uiswing/examples/layout/BorderLayoutDemoProject/src/layout/BorderLayoutDemo.java I also add frame.setSize(frame.getMaximumSize()); in createAndShowGUI()
I was following instructions from a Java website ( http://java.sun.com/docs/books/tutorial/essential/io/file.html#createStream ) on creating or
I'm following the example code here: http://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/output-example_8c-source.html My code is as follows: fmt =
I have the following code: urls <- c( xxxxx, http://stat.ethz.ch/R-manual/R-devel/library/base/html/connections.html, http://en.wikipedia.org/wiki/Xz ) readUrl <-
the example code on the boost website is not working. http://www.boost.org/doc/libs/1_46_1/libs/filesystem/v3/doc/tutorial.html#Using-path-decomposition int main(int argc,
Running the following Code var_dump(get_headers(http://www.domainnnnnnnnnnnnnnnnnnnnnnnnnnnn.com/CraxyFile.jpg)); Returns HTTP 200 instead of 404 For any domain
I'm having problems doing the Database example from PhoneGap. http://docs.phonegap.com/phonegap_storage_storage.md.html#openDatabase The Problem is, when
I tried installing Hadoop following this http://hadoop.apache.org/common/docs/stable/single_node_setup.html document. When I tried executing this bin/hadoop
The following code alerts ls exist in IE7: if(window.localStorage) { alert('ls exists'); } else
I have the following code, and I would like to add some HTTP header

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.