• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

doubt in page 494 of HFSJ  RSS feed

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a doubt in understanding <jsp aram> variable scope.
Just for testing i wrote the following code inside a Test.jsp.
<form action="TestServlet>
<jsp:include page="hello/second.jsp">
<jsp aram name="username" value="marcus"/>
</jsp:include>
<%
out.print(request.getParameter("username"));
%>
</form>
This JSP displays the username value as null which is valid.But,i would like to know what is scope of <jsp aram > variables .If i submit the above form to TestServlet ,will i able to retrieve username value.I even tested by submitting the value to TestServlet and i got username value as "null".What is the scope of <jsp aram> variables ? Will it be available only to the included page.If so,how it is different from tag files. When we use tag files,we use tag attributes which are visible only in inculded pages.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scope of <jsp aram --- > is Request but you can access it only in hello/second.jsp file, not in TestServlet.
There is no much difference between <jsp:include> and Tag, One major difference is if you use <jsp:include> you are going to land up with nested two <html> opening and </html> closing tags.
Take for example,if you include a page using <jsp:include> :

<%@ page import="...." %>
<html> <body>
<jsp:include page="hello/second.jsp">
<jsp: param name="username" value="marcus"/>
</jsp:include>
</body> </html>

hello/second.jsp
<html> <body> <%=request.getParameter("username"); %> </body> <html>

Your final JSP page will end up with repetition of tags. In order to aviod this you can go for Tags.
To tag file, you dont send request parameters, you send tag attributes.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!