Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » relative path for web app
relative path for web app [message #505190] Mon, 28 December 2009 08:45 Go to next message
Simone  is currently offline Simone Friend
Messages: 1
Registered: December 2009
Junior Member
Hello,
I am developing a web application in jsp with Eclipse 3.2 WTP all-in-one, Tomcat 5.5 (I followed tutorial on eclipsetotale.com) .
I would like to place an image in the application but I can not give the path relative to my application to find the file. Jpg.
The folder of Eclipse and 'installed in c: \ eclipse while the project in c: \ workspace \ ProgettoBeta \

I created a folder for the images in c: \ workspace \ ProgettoBeta \ images \ with a file inside logo.jpg
the path in the code and check that 'this

". / ProgettoBeta / images / Logo.jpg"

When I try to load the application and found the error 'The following
Code:

C:\eclipse\.\ProgettoBeta\images\Logo.jpg (The system cannot find the path specified)
java.io.FileNotFoundException: C:\eclipse\.\ProgettoBeta\images\Logo.jpg (The system cannot
find the path specified)
   at java.io.FileInputStream.open(Native Method)
   at java.io.FileInputStream.<init>(FileInputStream.java:106)
   at java.io.FileInputStream.<init>(FileInputStream.java:66)
   at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
   at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
   at java.net.URL.openStream(URL.java:1010)
   at com.itextpdf.text.Image.getInstance(Unknown Source)
   at com.itextpdf.text.Image.getInstance(Unknown Source)
   at org.me.betaLib.GeneraPdf.creaPdf(GeneraPdf.java:47)
   at org.me.betaLib.Controller.doGet(Controller.java:62)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)

   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)

   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection
(Http11BaseProtocol.java:665)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
   at java.lang.Thread.run(Thread.java:619)



From what i read the source path is 'C: \ eclipse instead of' the project folder and this puts me in error.
how can I resolve the situation?
Thanks
Re: relative path for web app [message #505701 is a reply to message #505190] Mon, 04 January 2010 10:12 Go to previous message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
Simone wrote:
> Hello, I am developing a web application in jsp with Eclipse 3.2 WTP
> all-in-one, Tomcat 5.5 (I followed tutorial on eclipsetotale.com) .
> I would like to place an image in the application but I can not give the
> path relative to my application to find the file. Jpg. The folder of
> Eclipse and 'installed in c: \ eclipse while the project in c: \
> workspace \ ProgettoBeta \
> I created a folder for the images in c: \ workspace \ ProgettoBeta \
> images \ with a file inside logo.jpg the path in the code and check that
> 'this
> ". / ProgettoBeta / images / Logo.jpg"
> When I try to load the application and found the error 'The following Code:
>
> C:\eclipse\.\ProgettoBeta\images\Logo.jpg (The system cannot find the
> path specified)
> java.io.FileNotFoundException: C:\eclipse\.\ProgettoBeta\images\Logo.jpg
> (The system cannot
> find the path specified)
> at java.io.FileInputStream.open(Native Method)
> at java.io.FileInputStream.<init>(FileInputStream.java:106)
> at java.io.FileInputStream.<init>(FileInputStream.java:66)
> at
> sun.net.www.protocol.file.FileURLConnection.connect(FileURLC onnection.java:70)
>
> at
> sun.net.www.protocol.file.FileURLConnection.getInputStream(F ileURLConnection.java:161)
>
> at java.net.URL.openStream(URL.java:1010)
> at com.itextpdf.text.Image.getInstance(Unknown Source)
> at com.itextpdf.text.Image.getInstance(Unknown Source)
> at org.me.betaLib.GeneraPdf.creaPdf(GeneraPdf.java:47)
> at org.me.betaLib.Controller.doGet(Controller.java:62)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFi lter(ApplicationFilterChain.java:269)
>
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(App licationFilterChain.java:188)
>
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(Standar dWrapperValve.java:213)
>
> at
> org.apache.catalina.core.StandardContextValve.invoke(Standar dContextValve.java:174)
>
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHo stValve.java:127)
>
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorRepo rtValve.java:117)
>
>
> at
> org.apache.catalina.core.StandardEngineValve.invoke(Standard EngineValve.java:108)
>
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAd apter.java:174)
>
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Proce ssor.java:874)
> at
> org.apache.coyote.http11.Http11BaseProtocol$Http11Connection Handler.processConnection
>
> (Http11BaseProtocol.java:665)
> at
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(Poo lTcpEndpoint.java:528)
>
> at
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt( LeaderFollowerWorkerThread.java:81)
>
> at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.ru n(ThreadPool.java:689)
>
> at java.lang.Thread.run(Thread.java:619)
>
>
>
> From what i read the source path is 'C: \ eclipse instead of' the
> project folder and this puts me in error.
> how can I resolve the situation?
> Thanks

There is no guarantee as to what folder "." will refer to in a servlet
container, such as Tomcat. It's not clear what GeneraPdf.creaPdf() or
Image.getInstance() will use as the algorithm for resolving a relative
image URL, so it is hard to say much more than using "." isn't going to
work. I wouldn't be surprised if your options are limited and you have
to specify something absolute. If you put the image under a
"WebContent\images" folder of the project, then it should be accessible
via the served webapp using the URL
"http://localhost:<port>/ProgettoBeta/images/Logo.jpg".

Cheers,
Larry
Previous Topic:eclipse with glassfish
Next Topic:Missing classes in WST Tomcat server execution
Goto Forum:
  


Current Time: Fri Apr 19 01:11:09 GMT 2024

Powered by FUDForum. Page generated in 0.03203 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top