I'm having problem to initiate my applet, e.g. is it possible to have JSP page outside WEB-INF to call an applet class that is inside WEB-INF?
Short answer NO The whole design of the servlet API is intended to keep the data under WEB-INF hidden from browsers. It is illegal for a server to directly serve anything under WEB-INF - it is a very important security restriction. Your choices are: 1. Put your applet classes where the browser is allowed to request them - just like you were supporting an applet in a static HTML page. 2. Create a servlet to serve the applet classes from the WEB-INF location. Bill
Joined: Jan 15, 2002
Could you give me some guidelines on how to serve an applet class from my servlet?
Author and all-around good cowpoke
Joined: Mar 22, 2000
Serving an applet class is just like serving any other binary data from a file - the request is going to be a GET. you have to be sure to 1. use the response OutputStream (NOT the writer) 2. set the content-type to match what the browser is expecting (I can't remember what the type is for class files) 3. set the content-length to the actual length of the binary data - you can get that from the File length() method 4. read the file into a byte buffer and write it to the response output stream 5. close the output stream 6. be sure to catch and log any IOExceptions Bill
subject: Calling an Applet from JSP - applet not inited?