Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How to call a Servlet from an applet

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello
I have an applet, which contains a Button, on clicking that button I have to call an JSP page, which is in another m/c.I am viewing the applet via appletviewer, and I have to call it only through appletviewer because my other application is running via that.I am able to call the JSP page when I viewed the applet through IE.
Kindly help me to come out from this
Thanking you
regards
Kiran
 
Saloon Keeper
Posts: 24811
172
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
An applet can invoke a servlet, JSP, or even non-Java items like ASPs and CGIs by creating an HttpURLConnection. This works whether you're running in AppletViewer or in a browser (although browsers are limited to contacting the same server that the applet came from).
When you say "call" a JSP page, I'm assuming you mean to retrieve data, rather than to cause a new web page to be displayed somewhere. That's a different matter.
 
Kiran H Iyer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello Tim,
Pls advice me how to use the HttpUrlConnection class inside a applet as it is declared abstract.
pls help me with some codes.
thanks a lot
regards
Kiran
 
Tim Holloway
Saloon Keeper
Posts: 24811
172
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
I wish I had some code to show you, but it's sitting on a machine at my ex-employer. I recommend you grab a book on Java network programming, since it's what I'd have to do myself.
The way to get an HttpURLConnection is simply to define a URL object and use its openConnection() method. If the URL object refers to an http URL, like:
URL javaRanch = new URL("http://www.javaranch.com/cgi-bin/search?find=mongoose");
do:
HttpURLConnection javaRanchLink = (HttpURLConnection) javaRanch.openConnection();
The JavaDocs for HttpURLConnection's parent class have some useful info on them.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic