• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Path problem

 
Yewint Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi everybody.
I got a little problem ........



and , the following is my servlet "ShowImageServlet.java"



I put "images" dir in the "Yewint" dir first.When I run my application, the whole page was displayed correctly,but the image("me.jpeg") was not displayed by the browser.I'm comfusing about where to put "images" dir in my app. I have tried over and over again putting "images" dir everywhere in my app.But I couldn't solve the problem. So,can anyone help me out please?

 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yewint. Use relative path
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best way to point to the image is to use absolute path including context path like this


That way your servlet can be mapped to any path and it will always work. Using a relative path might break if your servlet is mapped to a deep path like /myPath/myServlet ...

[Edit: changed getServeletRequest() to getServletContext()]
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit. I didn't find the method getServletRequest(). I think it is getServletContext().
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chinmaya Chowdary wrote:Hi Ankit. I didn't find the method getServletRequest(). I think it is getServletContext().


Yes it is, sorry, I'll correct it ...
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm comfusing about where to put "images" dir in my app. I have tried over and over again putting "images" dir everywhere in my app


You can place images , htmls anywhere inside Webapp except inside WEB_INF ( which the client browser cannot access it directly) .
 
Yewint Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you all...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic