Forums Register Login

HTTP Vs HTTPS

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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).]
+Pie Number of slices to send: Send
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).]
+Pie Number of slices to send: Send
James,
I didn't realize that I was taking the wrong approach until you pointed it out. Thanks for all your help.
-Akram
+Pie Number of slices to send: Send
 

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

Space pants. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1617 times.
Similar Threads
SSL with Jbuilder ?
SSL
How to connect to HTTPS url using java URL Class
Different Between Http and Https protocols
Using SSL on HttpURLConnection
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:21:50.