It's not a secret anymore!
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "while (unsolved) {BrickWall + Head}" Watch "while (unsolved) {BrickWall + Head}" New topic

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

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.
- satya

Take a Minute, Donate an Hour, Change a Life
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.*;
public class Test1 extends HttpServlet
int i = 0;
public void service(HttpServletRequest req, HttpServletResponse res) throws IOExce
PrintWriter out = res.getWriter();
out.println("My servlet!");
out.println("<h1>Test Page 1 hits: " + i++);
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>");
Am I doing something wholly flawed here?
Thanks for you help.
William Brogden
Author and all-around good cowpoke

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