Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

while (unsolved) {BrickWall + Head}

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[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
 
Declan Conlon
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
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
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 will open the floodgates of his own worst nightmare! All in a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic