my dog learned polymorphism
The moose likes Servlets and the fly likes Applet &Servlet communication(Tunneling) in tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Applet &Servlet communication(Tunneling) in tomcat" Watch "Applet &Servlet communication(Tunneling) in tomcat" New topic

Applet &Servlet communication(Tunneling) in tomcat

nan sh
Ranch Hand

Joined: Jan 05, 2001
Posts: 167
For Applet & Servlet tunneling(using tomcat), I need to create a connect from Applet to Servlet, where should I connect to ? to where servlets physically stay(like tomcat/webapps/Myproject/Web-inf/classes/MyServlet.class) or the thing we type in URL in browser(like localhost:8080/Myproject/MyApplet.class)?
Say I have,

In, I have code as;

URL currentPage = getCodeBase();
String protocol = currentPage.grtProtocol();
String host = currentPage.getHost();
int port = currentPage.getPort();
// String urlSuffix = "/MyServlet" //line 1
// String urlSuffix = "Web-inf/classes/MyServlet" //line 2
URL dataURL = new URLprotocol, host,port,urlSuffix);
URLConnection connection = dataURL.openConnection();

which one is correct line1 or line2 ?
(I use core Servlets & JavaServer Pages by Marty Hall)

Have you tried this Mock Exam Testing Engine yet?<br /><a href="" target="_blank" rel="nofollow"></a>
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16541

You use the http. Just because you're inside a Java applet doesn't mean the web server has suddenly become a LAN server! You're still talking to a web server, so you implement the tunnel as an http request.
Line 1
[This message has been edited by Tim Holloway (edited September 11, 2001).]

Customer surveys are for companies who didn't pay proper attention to begin with.
Have you tried LearnNowOnline?
subject: Applet &Servlet communication(Tunneling) in tomcat