wood burning stoves
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
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 MyApplet.java, 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="http://www.mycgiserver.com/~nan111/index.html" target="_blank" rel="nofollow">www.mycgiserver.com/~nan111/index.html</a>
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

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).]

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link: http://aspose.com/file-tools
subject: Applet &Servlet communication(Tunneling) in tomcat
jQuery in Action, 3rd edition