This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes while (unsolved) {BrickWall + Head} Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "while (unsolved) {BrickWall + Head}" Watch "while (unsolved) {BrickWall + Head}" New topic
Author

while (unsolved) {BrickWall + Head}

Declan Conlon
Ranch Hand

Joined: Jul 03, 2001
Posts: 34
The page won't display the applet;
here's the code;
out.println("<img src=\"../images/code.gif\" height=24 width=24 align=right border=0 alt=\"view code\">");
out.println("<APPLET CODE=\"../images/Test1.class\" WIDTH=150 HEIGHT=120>");
[Using jsdk, with default settings]
Any new light on the subject would be great. This seems like the sort of problem I'm not going to solv unless i'm told.
Documentation is useless, as I've placed my applet in every sub directory of /examples and still it can't be found. I've restarted the server and still nothing. I'm new to this stuff so what do I need to do to get the server and or servlet to find the class file. Problem as I see it is due to the fact images are shown perfectly?? Both accessed from the same directory.
Thanks to the person who can help me out here.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
[B]

[/B]
I would replace the escapes (\") like this and try:

Also, if the only choice is a head against brickwall, I would
set the content type to "text/plain" instead of "text/html" and see what type of HTML (in text form) this servlet is generating.
You may get the clue from that text HTML.
regds.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Declan Conlon
Ranch Hand

Joined: Jul 03, 2001
Posts: 34
Tried the suggestions and still no sign of the applet. Here's the code in full and other suggestions would be great.
/** Test java servlet to print some HTML and download an applet **/
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Test1 extends HttpServlet
{
int i = 0;
public void service(HttpServletRequest req, HttpServletResponse res) throws IOExce
ption
{
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
out.println("<HTML>");
out.println("<HEAD><TITLE>");
out.println("My servlet!");
out.println("</TITLE></HEAD><BODY>");
out.println("<h1>Test Page 1 hits: " + i++);
out.println("<br>");
out.println("<br>");
out.println("<img src='../images/code.gif' height=24 width=24 align=right border=0 alt='view code'>");
out.println("<APPLET CODE='../images/TestApp.class' WIDTH=150 HEIGHT=120>");
out.println("</APPLET>");
out.println("</h1></BODY>");
out.println("</HTML>");
out.close();
}
}
Am I doing something wholly flawed here?
Thanks for you help.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
The problem is the use of relative URL in
'../images/TestApp.class'
The browser can't resolve that because it thinks the page came from something like: http://serveradr/servlet/theServlet
Solutions:
1) use a <BASE tag in the <HEAD area of the page to define where the class files should come from.
-or-
2) write only absolute URLs for all resources
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: while (unsolved) {BrickWall + Head}