• 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

Question regarding jsp:include

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand that <jsp:include> action is used when dynamic content in JSP is needed versus the <%@ include%> directive while using static files.

I have a piece of code with which I am not able to justify the above.

CheckBeanProp.jsp

code:
--------------------------------------------------------------------------------

<input type="text" name="Meera" value="Help">
<jsp:include page="includeresult.jsp" />

--------------------------------------------------------------------------------



includeresult.jsp

code:
--------------------------------------------------------------------------------

Value of textbox : ${param.Meera}

--------------------------------------------------------------------------------



If I understand right,
the servlet class for CheckBeanProp.jsp will be created and a method call will be inserted in the servlet code (after setting the "Meera" parameter) to call includeresult.jsp at Runtime.
So, the "Meera" parameter should be set to "Hello" in includeresult.jsp.

The actual output thst I get is nothing, that is no parameter that is set in the request.

Why does this code not work? If not this way, how should I best use the <jsp:include> action when I need dynamic output during deployment.

Where am I going wrong?
[ June 21, 2006: Message edited by: Deepti Padiyar ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Deepti Padiyar:
I understand that <jsp:include> action is used when dynamic content in JSP is needed versus the <%@ include%> directive while using static files.



Your understanding is not correct. Either type of include can be used whether the included file is dynamic or static.

The difference is that with the include directive, the inclusion takes place at translation time, while with the include action, the inclusion occurs at execution time.


<input type="text" name="Meera" value="Help">
<jsp:include page="includeresult.jsp" />

If I understand right,



You do not. What led you to believe that the input element would be submitted to the include? As far as JSP is concerned, the input element is just template text and has no meaning at all. It might well have been "asjdhsakjdhskjhdsakjdhska" as far as the JSP processor is concerned.


If not this way, how should I best use the <jsp:include> action when I need dynamic output during deployment.



That very much depends upon what you mean by "dyanmic output".
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The includedreslt.jsp , and the CheckBeanProp.jsp could display the the value of the property after the form has been submitted once.
When the form is submitted, the text field will put its' values onto request parameters.

Then we can read these request parameters and stuff them into the value for the text field, and then pass it as a parameter to the included file.

CheckBeanProp.jsp:


note that your URI for the taglibrary would probably be different.

includeresult.jsp


Note i used the <c:out jstl tag instead of the inline expression language, in case your webapp does not use the servlet 2.4 deployment descriptor, which would not enable expression language scriptlets loose in the jsp (that happended to me once )
 
reply
    Bookmark Topic Watch Topic
  • New Topic