You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Oskar Zinger <os...@micromuse.com> on 2001/06/02 20:45:13 UTC
get/setAttribute and getParameter...
Hi,
What is more time consuming?
JSP1:
<% request.setAttribute("FLAG", new Boolean("true")); %>
<jsp:include page="JSP2.jsp" flush="true"/>
JSP2:
<% boolean FLAG = ((Boolean)
request.getAttribute("FLAG")).booleanValue();
if (FLAG) {
..........
...........
}
%>
OR?:
JSP1:
<jsp:include page="JSP2.jsp?FLAG=true" flush="true"/>
JSP2:
<% String FLAG = request.getParameter("FLAG");
if (FLAG.equals('true")) {
..........
..........
}
%>
OR?:
JSP1:
<jsp:include page="JSP2.jsp?FLAG=true" flush="true"/>
JSP2:
<% boolean FLAG = (new
Boolean(request.getParameter("FLAG"))).booleanValue();
if (FLAG) {
..........
..........
}
%>
AND, which way is it best practiced.
Thankss for any help!
--
Oskar Zinger
Re: get/setAttribute and getParameter...
Posted by "Moin Anjum H." <mo...@yahoo.com>.
Hi,
I am not sure which is the best way. I usually use the First one for my
job.
Regards
Moin.
Oskar Zinger wrote:
> Hi,
> What is more time consuming?
>
> JSP1:
> <% request.setAttribute("FLAG", new Boolean("true")); %>
> <jsp:include page="JSP2.jsp" flush="true"/>
>
> JSP2:
> <% boolean FLAG = ((Boolean)
> request.getAttribute("FLAG")).booleanValue();
> if (FLAG) {
> ..........
> ...........
> }
> %>
>
> OR?:
>
> JSP1:
> <jsp:include page="JSP2.jsp?FLAG=true" flush="true"/>
>
> JSP2:
> <% String FLAG = request.getParameter("FLAG");
> if (FLAG.equals('true")) {
> ..........
> ..........
> }
> %>
>
> OR?:
>
> JSP1:
> <jsp:include page="JSP2.jsp?FLAG=true" flush="true"/>
>
> JSP2:
> <% boolean FLAG = (new
> Boolean(request.getParameter("FLAG"))).booleanValue();
> if (FLAG) {
> ..........
> ..........
> }
> %>
>
> AND, which way is it best practiced.
>
> Thankss for any help!
> --
> Oskar Zinger
Re: get/setAttribute and getParameter...
Posted by Hemant Singh <he...@yahoo.com>.
HI Zinger:
answer to this question depends on env conditions
setAttribute method stores the attribute in JVM itself for every session,
while set parameter will pass the attribute as a header information to you
new jsp.
So it all depends on memory available, cpu speed, and no of pages you are
going to use this technique.
Cheers
Hemant
----- Original Message -----
From: "Oskar Zinger" <os...@micromuse.com>
To: "TomcatDev" <to...@jakarta.apache.org>;
<to...@jakarta.apache.org>
Sent: Sunday, June 03, 2001 12:15 AM
Subject: get/setAttribute and getParameter...
> Hi,
> What is more time consuming?
>
> JSP1:
> <% request.setAttribute("FLAG", new Boolean("true")); %>
> <jsp:include page="JSP2.jsp" flush="true"/>
>
> JSP2:
> <% boolean FLAG = ((Boolean)
> request.getAttribute("FLAG")).booleanValue();
> if (FLAG) {
> ..........
> ...........
> }
> %>
>
> OR?:
>
> JSP1:
> <jsp:include page="JSP2.jsp?FLAG=true" flush="true"/>
>
> JSP2:
> <% String FLAG = request.getParameter("FLAG");
> if (FLAG.equals('true")) {
> ..........
> ..........
> }
> %>
>
> OR?:
>
> JSP1:
> <jsp:include page="JSP2.jsp?FLAG=true" flush="true"/>
>
> JSP2:
> <% boolean FLAG = (new
> Boolean(request.getParameter("FLAG"))).booleanValue();
> if (FLAG) {
> ..........
> ..........
> }
> %>
>
>
> AND, which way is it best practiced.
>
> Thankss for any help!
> --
> Oskar Zinger