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

Included file types in JSP

 
Nidhi Sar
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For including another file in a jsp using any of the following methods:

<%@include file="xyz" %>
<jsp:include page="xyz" />
<c:import url="http://www.example.com/xyz" />


Other than .html or .jsp , can xyz be something else - e.g. a .png or .jpeg file?

Edit: Edited for clarity.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64192
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think about how that might make any sense.
 
Nidhi Sar
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I was kindof hoping that including a .png would sort of insert a picture right there!

But I see why that wouldn't work ... trying to insert a binary file in middle of a page that is written using jsp language & destined to be translated to a java servlet code.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64192
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nidhi Sar wrote:But I see why that wouldn't work ... trying to insert a binary file in middle of a page that is written using jsp language & destined to be translated to a java servlet code.

Right, except that it has nothing to do with translation to a servlet -- remember that a JSP is a template for an HTML page. And you can't just plop binary image data down into the middle of HTML.
 
Nidhi Sar
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:And you can't just plop binary image data down into the middle of HTML.


Hmmm, makes sense. But just wondering about something. This might be a silly question, but how does the <img> tag manage to do exactly that... insert binary data right in middle of HTML?

<!-- Some HTML -->
<img src="horse.jpg" width="104" height="142" />
<!-- Some more HTML -->

If HTML <img> tag can do it, why cannot the JSP include statements?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64192
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The <img> tag causes a completely separate request to be made to fetch the image data. It does not just dump the binary data into the middle of the response that returns the HTML.
 
Nidhi Sar
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, that's clear now. Thanks for the answers and thanks for your patience.

- Nidhi
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic