• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

HTTP Vs HTTPS

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 25483
180
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Akram Reja
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
James,
I didn't realize that I was taking the wrong approach until you pointed it out. Thanks for all your help.
-Akram
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

 
Grow a forest with seedballs and this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic