Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing app accessing a servlet.  RSS feed

 
Eduardo Cobian
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I have to design a java based app that accesses a web-based app. I have decided to access a servlet through http rather than accessing the EJB tier.
Could anyone,please, explain to me how this can be done?
I guess the servlet must be a different one that the web customers are accessing.Right?
I would appreciate very much your help.
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not necessarily. The same servlet that lists a text file in a web browser can be used to with an applet to allow that applet to read and process the text.
Use the URLConnection class to form an HTTP request internal to the applet and receive the server's response. The server can only tell the difference between an applet-generated request and a browser-generated one by looking at the headers and noting that the requesting client program wasn't something like Internet Explorer.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, it doesn't even need to be an applet. You can make a Swing based GUI application that uses the URLConnection class. This would be somewhat like coding a browser, but it is possible.
 
Eduardo Cobian
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the answer.
It the servlet calls jsp pages to show output to the client, I guess that the applet can't use that servlet and a specific servlet has to be done.
Is that correct?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!