Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we pass request object to a included file

 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we pass the request object to the included file.
i.e the file included in both ways directive include and action include.
will the request object be accessible. and if I want to pass a parameter to the included file (file included through action include) how do I pass it.
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello chandra,
If we are doing static include (i.e. <%@page include %> than the content of the included file become part of the original file. So there is no question of passing request object. As they are treated like one servlet.
In the dynamic include(i.e. <jsp:include> ) request is forwarded using request dispatcher, hence the same request is forwarded.
Also i will advice you to take a look at some jsp tutorial, there are many available online. Like
JSP Tutorial
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chandra,

Can we pass the request object to the included file.
i.e the file included in both ways directive include and action include.

I think you can do this for dynamic inclusion ONLY. For static inclusion, the request object does not exist in the compliation time. It exists only in Runtime.
In addition, what request object you want to pass?
seems to me that the parameter tag inside the JSP action is the name value pair, which is expected to be Strings, or any data that can convert to String, like "True", "1", etc

will the request object be accessible. and if I want to pass a parameter to the included file (file included through action include) how do I pass it.

If you are talking about parameter, you can do that by:

Hope this help.
Nick.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition, in case I misuderstand your question, the request itself, will be forwarded to the included page automatically, if the 2 pages (or more) are requests by the same request.
Nick.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic