wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 60799
    
  65

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: 60799
    
  65

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: 60799
    
  65

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
 
Don't get me started about those stupid light bulbs.
 
subject: Included file types in JSP
 
Similar Threads
String constant pool or heap
Scriptlet in STRUTS 2
Properties file issue
.Xls file for xml to html conversion
where to use jar files in a jsp project