• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet-Applet communication in a WAR  RSS feed

 
andreas krohn
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a servlet and an applet that communicates with each other. This works fine in Orion, so the code should be fine. However, in JBoss I have a problem. There I need to deploy a WAR file and I put the servlet in WEB-INF/classes and the applet.jar in the root of the WAR. Now the applet can not create a connection with the servlet. I can reach the servlet in a browser with the URL I am using to create the URLConnection, so the URL should be OK.
What am I doing wrong? Is there a problem with having the applet and the servlet in the same WAR? If I should not have the applet in the WAR does anybody know where I should deploy it in JBoss?
Thank you
/Andreas
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by andreas krohn:
I put the servlet in WEB-INF/classes and the applet.jar in the root of the WAR.

In a Web Application, all jar files should be in the WEB-INF/lib directory.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jessica wrote: In a Web Application, all jar files should be in the WEB-INF/lib directory.
In this case I don't think that's right. This is a jar for an applet to download, so it should be in the root of the WAR.
To the original poster: are you sure that your applet is using the correct URL, including the deployed name of the web application?
 
andreas krohn
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the servlet URL I am currently hardcoding (for testing purposes) into my applet works fine if I just cut and paste it into a browser, and it includes the name of the deployed web app. So I do think the URL is correct.
/Andreas
 
andreas krohn
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently I also have the same problem when tyring to access my servlet from JSP, all files are within the same WAR. Tried the time honored "ignoring the problem and it will go away" approach, but so far no luck.
/Andreas
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember, the applet jar is loaded by the browser using either an absolute URL or one relative to the URL it used to get the page. When it gets the page from a servlet, it can't use that URL to load the jar.
Solution: The Jar MUST be in a directory that the browser is allowed to see, either code an absolute URL or use a base tag in the head region of the generated page.
Bill
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!