• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet &Servlet communication(Tunneling) in tomcat

 
nan sh
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
tomcat/webapps/Myproject/Web-inf/classes/MyServlet.class
tomcat/webapps/Myproject/MyApplet.class

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)
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18281
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic