• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need clarification for jsp:include.

 
Ranch Hand
Posts: 30
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider this two JSPs: -

Code for Page1.jsp (incldes Page2.jsp)


<HTML>
<BODY>
<FORM>
<TABLE>
<TR><TD>********</TD></TR>
</TABLE>
</FORM>
<jsp:include page="Page.jsp">
</BODY>
</HTML>



Code for Page2.jsp


<FORM>
<TABLE>
Some data coming from database
</TABLE>
</FORM>



When i did this and deployed my application and viewd Page1.jsp in the Internet Explorer I was able to see the contents of Page1.jsp and not Page2.jsp. However, when I viewed the page source of Page1.jsp from the browser it contains the source of Page2.jsp along with data coming from the database.

And now I had made a small change in Page1.jsp

Modified code for Page1.jsp (includes Page2.jsp)


<HTML>
<BODY>
<FORM>
<TABLE>
<TR><TD><jsp:include page="Page.jsp"></TD></TR>
</TABLE>
</FORM>
</BODY>
</HTML>



I got the display of Page2.jsp also.

Can any one explain what happened earlier?

K.Anutosh
---------------------------------------------------------------------------
SCJP 1.4
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the problem is with your HTML. If your code for the table was in fact just as you've shown, you might not get to see the data. That's probably why you could see it in the source but it wasn't rendered by the browser.

Remember, <table> should have <tr> and that should have <td> which should hold the actual data. Anywhere else, and you might see nothing!
 
Anutosh Swamy
Ranch Hand
Posts: 30
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Tarun,

The actual code of Page2.jsp is having a lots of <TR> and <TD> inside the table tag which is holding the data coming from database I just skipped it in this forum.

And, in Page1.jsp the code "<TR><TD>********</TD></TR>" is nothing but <TR><TD></TD></TR>, I just starred it because to attract the attaintion of the ranchers as I had kept <jsp:include> there to make Page1.jsp to display the contents of Page2.jsp.

and if you need some more clarification on the code, most welcome.

My question is:-

When I kept my <jsp:include> out of the </TD>,</TR>,</TABLE></FORM> in Page1.jsp I was not able to see the display of Page2.jsp although the source was included (what's wrong here?), but when I put <jsp:include> inside </TD>,</TR>,</TABLE></FORM> in Page1.jsp I got the display (Why not in the former case?)

K.Anutosh
---------------------------------------------------------------------------
SCJP 1.4
[ October 25, 2007: Message edited by: Anutosh Swamy ]
 
Tarun Yadav
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are able to view the expected source code but only have a problem with the display, that suggests that there is a problem rendering your page. Especially since you've only moved the <jsp:include> a little higher into some template text; it doesn't affect the execution in anyway.

I can't think of anything else. If you posted the actual code for page, ( without all your data of course, maybe only one or two rows ), that might help. Also, try viewing it with another browser, that might help see if this is actually the cause.
 
Anutosh Swamy
Ranch Hand
Posts: 30
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Tarun,

Thanks for the suggestion i'll try to run that application in another browser and I think that it will work.


K.Anutosh
---------------------------------------------------------------------------
SCJP 1.4
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic