This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Question regarding jsp:include 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 » Java » JSP
Bookmark "Question regarding jsp:include" Watch "Question regarding jsp:include" New topic
Author

Question regarding jsp:include

Deepti Padiyar
Ranch Hand

Joined: Apr 27, 2006
Posts: 31
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 ]

Regards,<br />Deepti.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

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".


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
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 )


Error: Keyboard not attached. Press F1 to continue.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question regarding jsp:include
 
Similar Threads
jsp:include throws Exception
Question regarding jsp:include
RequestDispatcher
jsp:include using jsp_precompile question
Runtime Expression Value in jsp:forward