navrsalemile
Programmer
I have a class which sets session parameters using
session.putValue( "param1", "value1");
session.putValue("param2", "value2");
and then redirects to a JSP page:
response.sendRedirect( "
somepage.jsp retrieves session params using this scriptlet:
<%
String param1 = "";
Object o = pageContext.getAttribute("param1", PageContext.SESSION_SCOPE );
if ( o != null ) {
param1 = o.toString();
out.println("param1 = " + param1);
}
String param2 = "";
o = pageContext.getAttribute("param2", PageContext.SESSION_SCOPE );
if ( o != null ) {
param2 = o.toString();
out.println("param1 = " + param2);
}
%>
...
<%@ include file="header.jsp" %>
...
<%
if (param2.compareTo("") != 0 ) {
out.flush();
pageContext.include( "welcome_" + param2 + ".jsp );
}
else {
out.println( "page not included")
%>
...
<%
if (param1.compareTo("") != 0) {
out.flush();
pageContext.include( param1 + ".jsp" );
else {
%>
...
<%@ include file="footer.jsp" %>
But the attributes retrieved from session here are nulls as I get message "page not included".
Isn't sendRedirect() supposed to preserve the session and only create a new http request!?
thanks,
mile
session.putValue( "param1", "value1");
session.putValue("param2", "value2");
and then redirects to a JSP page:
response.sendRedirect( "
somepage.jsp retrieves session params using this scriptlet:
<%
String param1 = "";
Object o = pageContext.getAttribute("param1", PageContext.SESSION_SCOPE );
if ( o != null ) {
param1 = o.toString();
out.println("param1 = " + param1);
}
String param2 = "";
o = pageContext.getAttribute("param2", PageContext.SESSION_SCOPE );
if ( o != null ) {
param2 = o.toString();
out.println("param1 = " + param2);
}
%>
...
<%@ include file="header.jsp" %>
...
<%
if (param2.compareTo("") != 0 ) {
out.flush();
pageContext.include( "welcome_" + param2 + ".jsp );
}
else {
out.println( "page not included")
%>
...
<%
if (param1.compareTo("") != 0) {
out.flush();
pageContext.include( param1 + ".jsp" );
else {
%>
...
<%@ include file="footer.jsp" %>
But the attributes retrieved from session here are nulls as I get message "page not included".
Isn't sendRedirect() supposed to preserve the session and only create a new http request!?
thanks,
mile