• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to Call Applets from Servlets

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dear ,
i created a HTML page for entering the booth number an password. The entered details are passed to a servlet using
< FORM ACTION="login" METHOD="POST"> written inside html page
Where login is the name given to the servlet which connects the Database and verify the password in the DB table.
Then the appropriate message is displayed.
It's coded through the servlet ( no explicit html page is created for it)
using
out.println("<html>"); ................ in the servlet.
......................................................
out.println("<FORM ACTION=\"voterlogin\" METHOD=\"POST\">");
..................
out.println("Your Booth is Connected To The Server</H1>\n");
.....................................
out.println("<INPUT TYPE=Submit VALUE=\" OK \">");
When i press the submit button in the message window, it should get the applet display for entering the voter's password.
voterlogin is another servlet, inside which i wrote the code for the next display window
out.println("<html>");
out.println("<head>");
...........................
out.println("<P><APPLET CodeBase=.. CODE=\"voterpassword.class\" WIDTH=500 HEIGHT=500</APPLET><P>");
where voterpassword is an applet for displaying voter's password entry.
Here the problem comes
I am not able to get the applet displayed in the web-browser.
Where the problem lies. ???
How to write the CodeBase
Where exactly should i put the applet file in the TomCat directory
TomCat Root Context
<Context path="election" docBase="/election" debug="0" />

Directory structure is
webapps
|
--- election
|
---- WEB-INF
|
---- classes
|
----- OVS
where OVS is the package i used for classes which is used to enter initial details into the Database, like details about the election.
I put the servlets in the same directory, so inorder to keep that order, i created the OVS directory in webserver and put the servlets into OVS in the webserver.
Now the question is where to place applets in the webserver and
how to write the code in servlets so that applet will be displayed in the web-browser. ( also, How to write the CodeBase)
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Recall that applet classes must be where the browser can request them - therefore they can't be placed under WEB-INF. In the absense of other instructions, the browse will request applet classes from the url the page came from - which in this case is the servlet address and your relative address of ".." won't work.
The best solution I have found is to use the HTML BASE tag to tell the browser how to form request URLs for things like images and applet classes from relative paths.
Alternately you could give a complete URL for the codebase.
Bill
reply
    Bookmark Topic Watch Topic
  • New Topic