• 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

HELP! Weird Include problem!

 
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using tomcat 4.1.18. When I used tomcat 3.2 I had no problem with this. Here's what I discovered:
When I include a page (has a teeny bit of JSP code, but mostly houses JavaScript code for client-side) as such:
<jsp:include page="/includes/header.jsp" flush="true" />
It only includes the bottom half of that header file. So half my javascript doesn't show up.
If i use the following:
<%@ include file="/includes/header.jsp" %>
I get a buffer overflow.
If I use the following:
<% getServletConfig().getServletContext().getRequestDispatcher( "/includes/header.jsp" ).include( request, response ); %>
NO PROBLEM AT ALL! Why is this?
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat 3.2 was a bit more forgiving (which it shouldn't have been) about mal-formed JSP tags. One example I can think of in my own past, was that I was forgetting to put the /> to end a singleton tag, but 3.2 didn't care.

Once I moved to 4.x it took forever and a day to figure it out.

Is the tiny bit of JSP in that included page behaving ? are you sure?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another possibility is whether it is resulting in static or dynamic includes.
Sometimes an include statement results in a C style #include, where the JSP code is added to the same source file and there is a single Class output.
Dynamic includes create a separate Class for each JSP, execute them separately and then concatenate the output.
I'm not going to guess on the behaviour in your case, it's relatively vendor specific and just a useful thing to keep in mind.
There are pro's and con's to both but it is a long discussion and may have been discussed before. I recommend a search first.
Hope this helps you out though...
Dave
 
Author
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sometimes an include statement results in a C style #include, where the JSP code is added to the same source file and there is a single Class output.
Dynamic includes create a separate Class for each JSP, execute them separately and then concatenate the output.
I'm not going to guess on the behaviour in your case, it's relatively vendor specific and just a useful thing to keep in mind.


Actually, this is not vendor specific.
The jsp:include action includes the output of the included page. The included page gets invoked at request time. The main page and the included page are two separate servlets.
The @include directive includes the source of the included file. The included file gets merged into the main file at page-translation time. The main page and the included file become one big servlet.
Cheers-
- Marty
[ February 13, 2003: Message edited by: Marty Hall ]
 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
marty,
sure, but why does it result in buffer overflow as @include but not jsp:include?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marty Hall:
Actually, this is not vendor specific.


You're right, but it still relyies on the vendor implementing it correctly. I still tend to refer to it as vendor specific so that people don't just accept the behaviour without trying it out on their container first.
We're talking a few years now, but the behaviour of this changed dramatically in the BEA WebLogic server (4.51 and 5.1, I think).

Originally posted by Robert Paris:
sure, but why does it result in buffer overflow as @include but not jsp:include?


I'm not Marty but have you tried debugs to trace the flow? I can't think of anything off the top of my head to casue this (but then I'm still grogy from surgery yesterday), it would be pretty specific to your code.
Did you want to drop some sample code for us?
Dave
 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically in the include file all I have is:
(In bang definition, i.e. with a !)
1. String arrays holding global info like state names
2. method to check login
(regular)
1. HTML
2. JavaScript Code
What's weird is, if I remove the JAVASCRIPT code I don't get a buffer overflow!! What's up with that? Granted there is alot of JavaScript code, but still, isn't that weird?
 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
post your code, it will make your problem easier to understand
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Robert, could you define "alot"?
[ February 14, 2003: Message edited by: Mike Curwen ]
 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sure. If I put the javascript alone into a text file, it's 14K.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic