File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Included file types in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Included file types in JSP" Watch "Included file types in JSP" New topic
Author

Included file types in JSP

Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

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.


"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61772
    
  67

Think about how that might make any sense.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

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

Joined: Jan 10, 2002
Posts: 61772
    
  67

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

Joined: Oct 19, 2009
Posts: 252

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

Joined: Jan 10, 2002
Posts: 61772
    
  67

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

Joined: Oct 19, 2009
Posts: 252

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
 
subject: Included file types in JSP