File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Including a file in JSP

 
Hanna Habashy
Ranch Hand
Posts: 532
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to include a file in a jsp page. The application is running on linex.

I used:


But it is not working.
Any ideas?
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Error messages would be helpful ;)
 
Hanna Habashy
Ranch Hand
Posts: 532
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sebastian Janisch wrote:Error messages would be helpful ;)


The error message was file is not found. The file is there, however.
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a space after the quote sign.
Also, it looks like you are importing a directory and not a file.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that path relative to the app?
 
Hanna Habashy
Ranch Hand
Posts: 532
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Is that path relative to the app?

No, it is an absolute path.



The "/servername" is a mount point on the app server.
 
Hanna Habashy
Ranch Hand
Posts: 532
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can I provide a absolute path for C:import?

I tried this:

<c:import url="c:/announcement.txt" />


and I got MalformedURLExcption
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course not.

The path need to be relative to the web app root.
 
Hanna Habashy
Ranch Hand
Posts: 532
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Of course not.

The path need to be relative to the web app root.


Then, in the jsp page, how can I include a file that is outside the web server?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't.

If a file is to be included, it needs to be (and should be) a part of the web app.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic