This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question regarding jsp:include

 
Deepti Padiyar
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • 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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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".
 
Travis Hein
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • 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 <cut 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 )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic