Hi, I have a servlet that hits a JSP using the java.net.URL class. The URL is constructed during runtime. The code works fine with HTTP. But, with HTTPS, I get a MalformedURLException, with the message that HTTPS is unknown protocol. Is this because the URL class can only handle HTTP requests? If yes, is there a way around this problem? Any help would be appreicated. -Akram
Tim, I do mean a servlet. Marcos, one solution to this is to use RequestDispatcher.include(). The only problem with this is that you will be including the output from the JSP. My JSPs basically do NOT print any thing on to the screen, so I am okay with it, except that when there is an error in the JSP, the compilation errors are thrown on to the screen and I am looking for a way around it. Let me know if this helped/ if you know a solution. Thanks.
What you need is to download and install (have in classpaths) the JSSE package from sun.com Then you have to set some security parameters (it will be clear once you see the examples that come with it) and you should be able to use HTTPS without any problems.
Mak, I do not think that would solve my problem. HTTPS seems to be working fine in serving my other JSPs and HTML pages. So, I don't think that any thing is wrong with the way HTTPS is set up. Moreover, the servlet works fine if I use RequestDispatcher.include(). Thanks. -Akram
Mak was correct in saying that you need to use Java Secure Socket Extension (JSSE) (check out http://java.sun.com/products/jsse/) The standard java.net.* classes do not know how to handle SSL connections and that is why you are getting a MalformedURLException. Once you have the JSSE classes in your classpath you can then access new classes such as HttpsURLConnection which can then connect to a HTTPS resource. Other security properties are required to be set also, which are mentioned at Sun's website. James.
[This message has been edited by james swan (edited July 25, 2001).] [This message has been edited by james swan (edited July 25, 2001).]
Here is a simple example you can run from cmd line once you have downloaded JSSE classes from Sun (provided you are not behind a fire wall/proxy server configuration.
When you run this you should see the HTML that Yahoo sends when connecting to YahooMail via secure connection. James. [This message has been edited by james swan (edited July 25, 2001).]
Originally posted by Akram Reja: Hi, I have a servlet that hits a JSP using the java.net.URL class. The URL is constructed during runtime. The code works fine with HTTP. But, with HTTPS, I get a MalformedURLException, with the message that HTTPS is unknown protocol. Is this because the URL class can only handle HTTP requests? If yes, is there a way around this problem? Any help would be appreicated. -Akram
Hi, Akram Reja could you send me that code ? I've been trying to make a servlet that does a request on a JSP or HTML, compresses the response with gzip and return that to the client... I figured that with the right mapping patern, that can be very easy to return compressed JSP's to the client... only problem is that it doesn't work with JSP's !!! I don't know how comes.. my email is: davevaneven@hotmail.com (don't have to send everything, just the main code if possible) THANKS!!! (hope you read this ) Dave Van Even
Post by:autobot
Space pants. Tiny ad:
a bit of art, as a gift, that will fit in a stocking