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
Marcos Maia
Ranch Hand
Joined: Jan 06, 2001
Posts: 977
posted
0
hi, I�m having a problem very simmilar with this, if you sort it out please let me know, and if I do be sure that I�ll post here bye.
Do you mean servlet or applet? An applet might not be allowed to open an HTTPS connection unless it had been loaded from an HTTPS server.
Customer surveys are for companies who didn't pay proper attention to begin with.
Akram Reja
Greenhorn
Joined: Mar 13, 2001
Posts: 17
posted
0
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.
Maky Chopra
Ranch Hand
Joined: Apr 11, 2001
Posts: 149
posted
0
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.
Akram Reja
Greenhorn
Joined: Mar 13, 2001
Posts: 17
posted
0
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
James Swan
Ranch Hand
Joined: Jun 26, 2001
Posts: 403
posted
0
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).]
James Swan
Ranch Hand
Joined: Jun 26, 2001
Posts: 403
posted
0
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).]
Akram Reja
Greenhorn
Joined: Mar 13, 2001
Posts: 17
posted
0
James, I didn't realize that I was taking the wrong approach until you pointed it out. Thanks for all your help. -Akram
Dave Van Even
Ranch Hand
Joined: Jul 19, 2001
Posts: 101
posted
0
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
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.