In my jsp file I am pulling data from the request via request.getAttribute().
Inside this jsp I need to include another jsp. Will this inluded jsp have access to the request, or do I need to somehow forward on the data?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It will be available:
if you are doing a static include (
<%@ include file=".." %>) then the body of the included file is placed into thedoGet(..)method of the generated servlet (each JSP is converted to a servlet), so logically, the originalrequestobject is accessible there.if you are doing a dynamic include (
<jsp:include>),RequestDispatcher.include(..)is used (behind the scene). As you can see, it requires aServletRequestparameter, which would mean that the original request is passed there.Finally, avoid using Java code in JSP files. Use EL and JSTL. So instead of
request.getAttribute("x")this would be${x}.