aspose file tools*
The moose likes JSP and the fly likes Can we pass request object to a included file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Can we pass request object to a included file" Watch "Can we pass request object to a included file" New topic
Author

Can we pass request object to a included file

Chandra Bairi
Ranch Hand

Joined: Sep 12, 2003
Posts: 152
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.


Thanks,
Shekar
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
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


Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
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.


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
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.
 
Consider Paul's rocket mass heater.
 
subject: Can we pass request object to a included file