Hello All, I have written a servlet which works fine but I need to use a JPEG file as a background . I have given "<html><body background=\" something.jpg\" ><h1> Hello</h1></html> as atgs but it is not working. Can somebody help please? Thanks in advance Mamta
The problem is most likely one of the common "gotchas" with servlets... I guess you are using a url of the form http://host.org/servlets/MyServlet to access your servlet, so when the browser requests the image it creates a URL of the form http://host.org/servlets/something.jpg - which doesn't exist. The simple solution to this is to use a full URL in the "background" attribute, the complex solution involves setting up a servlet which serves images and matches URLs starting with "/servlets/" and ending in ".gif" and ".jpg" I hope this helps.
hello mamta, To get an image as a background change the mime type. That is generally we give res.setContentType("text/html") change it to res.setContentType("image/gif") hope this should solve your problem. bye madhavi.
Joined: Jan 07, 1999
The Java Ranch has a naming policy, described here and "mlbehra" is also not a valid name. Please choose one which meets the requirements. Thanks.
The alternative to using a full URL for each resource such as an image, applet or sound file is to specify a <BASE> tag in the <HEAD> area of the page your servlet generates. <base href="http://yourserver/some/path/" > Having that in only one place makes it easier to move the servlet around. Bill