Bear Bibeault wrote: Why does this surprise you, when that's exactly what you told it:
i wrote it so that the "image " will give me "tomcat.gif" or "jrun.gif" according to the condition , if that is wrong , please post what will be changed in that line or in the code .
Bear Bibeault wrote:Then why isn't that what you're specifying as the URL of the image in the <img> tag?
how can i put the image name directly in the image tab , i have made it a variable so that either "tomcat.gif" or "jrun.gif" will replace the image according to the condition .
Bear Bibeault wrote:And what's with the "servlet" prefix to the image files? Do you have a folder named "servlet"?
the prefix is to go inside \WEB-INF\classes folder because that's the place where i have my servlet & both images .
sir ,
one more thing should i add this line "res.setContentType("image/gif");" below this line "res.setContentType("text/html");"
because some mime(picture files) is used , i am not sure but may be.
---
TUSHAR
Shruthi Sam
Ranch Hand
Joined: Jul 09, 2008
Posts: 73
posted
0
Hi,
Change the below line in your code
out.println("<IMG SRC='/servlet/image'>");
to the following and try again
out.println("<IMG SRC='/servlet/"+image+"'>");
tushar panda
Ranch Hand
Joined: Feb 16, 2009
Posts: 133
posted
0
Shruthi Sam wrote:Hi,
Change the below line in your code
out.println("");
to the following and try again
out.println("");
not getting result , did that work for you .
Chuan Shao
Greenhorn
Joined: Aug 12, 2009
Posts: 5
posted
0
1. Don't put your images under /WEB-INF, otherwise, the browser cannot access the image directory through hyperlink.
2. If you print <img src='/servlet/tomcat.gif' /> on page, you are telling the browser to fetch /${YourWebAppRoot}/servlet/tomcat.gif
tushar panda
Ranch Hand
Joined: Feb 16, 2009
Posts: 133
posted
0
Chuan Shao wrote:1. Don't put your images under /WEB-INF, otherwise, the browser cannot access the image directory through hyperlink.
2. If you print <img src='/servlet/tomcat.gif' /> on page, you are telling the browser to fetch /${YourWebAppRoot}/servlet/tomcat.gif
i cannot understand ${YourWebAppRoot} . does it mean ROOT folder or a folder in root folder .
thanks brother got it
Chuan Shao
Greenhorn
Joined: Aug 12, 2009
Posts: 5
posted
0
tushar panda wrote:
Chuan Shao wrote:1. Don't put your images under /WEB-INF, otherwise, the browser cannot access the image directory through hyperlink.
2. If you print <img src='/servlet/tomcat.gif' /> on page, you are telling the browser to fetch /${YourWebAppRoot}/servlet/tomcat.gif
i cannot understand ${YourWebAppRoot} . does it mean ROOT folder or a folder in root folder .
thanks brother got it
yes, to make things easy, you can take ${YourWebAppRoot} as ROOT folder in tomcat.
tushar panda
Ranch Hand
Joined: Feb 16, 2009
Posts: 133
posted
0
Chuan Shao wrote:
yes, to make things easy, you can take ${YourWebAppRoot} as ROOT folder in tomcat.
if i create new folder under webapps , does i have to create a new WEB-INF folder inside it , or i can still access the default ROOT's WEB-INF folder .
Chuan Shao
Greenhorn
Joined: Aug 12, 2009
Posts: 5
posted
0
tushar panda wrote:
if i create new folder under webapps , does i have to create a new WEB-INF folder inside it , or i can still access the default ROOT's WEB-INF folder .
The answer is yes, if you create a new folder under webapps, you create a new web application, which needs its own deployment descriptor(web.xml) under its own WEB-INF directory.
tushar panda
Ranch Hand
Joined: Feb 16, 2009
Posts: 133
posted
0
one more thing :
does WEB-INF store only servlet files and nothing else
Shruthi Sam
Ranch Hand
Joined: Jul 09, 2008
Posts: 73
posted
0
The structure of a Web Application will be like this..
WebApplicationName/
Place your static files, such as HTML files and JSP files in this directory (or a subdirectory). This directory is the document root of your Web Application.
/WEB-INF/web.xml
The Web Application deployment descriptor that configures the Web Application.
Contains .jar files used by the Web Application, including JSP tag libraries.
Chuan Shao
Greenhorn
Joined: Aug 12, 2009
Posts: 5
posted
0
tushar panda wrote:one more thing :
does WEB-INF store only servlet files and nothing else
Information from the Java Servlet Specification 2.4:
---
The contents of the WEB-INF directory are:
• The /WEB-INF/web.xml deployment descriptor.
• The /WEB-INF/classes/ directory for servlet and utility classes. The classes
in this directory must be available to the application class loader.
• The /WEB-INF/lib/*.jar area for Java ARchive files. These files contain servlets,
beans, and other utility classes useful to the Web application. The Web application
class loader must be able to load classes from any of these archive
files.