Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JSP/Servlets: Best way to simulate request.setParameter()?

931 views
Skip to first unread message

Adam

unread,
Apr 13, 2002, 5:04:07 AM4/13/02
to
It's my understanding that there's no request.setParameter() or
anything equivalent. I'm currently storing a Properties value using
request.setAttribute() and dumping the request's parameters there at
the beginning of the servlet's request handler, then using that
exclusively in all the JSPs. This works, but it has some problems.
Particularly, unless I use a stack of Properties that gets pushed and
popped on every jsp:include (which I may do eventually) I can't
cleanly override parameter values for pages included from other pages,
as in:

<%= request.getParameter("param1") %> has a value here
<jsp:include page="included_page.jsp">
<jsp:param name="param1" value="aDifferentValue" />
</jsp:include>
<%= request.getParameter("param1") %> still has its old value here

I have to say
<%= properties.getProperty("param1") %> has a value here
<% properties.setProperty("param1","aDifferentValue"); %>
<jsp:include page="included_page.jsp" />
<%= properties.getProperty("param1") %> is now stuck with the new
value

Of course, I can always stick the original values somewhere and then
restore them after the include, but I'm hoping there's some option
that's a bit less ugly.

Thanks
Adam

0 new messages