• 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!