Link to home
Start Free TrialLog in
Avatar of aaaaaa
aaaaaa

asked on

session probluem

when i use email to open my web

<form action="http://localhost/mmmm.jsp" method=post>
<input type=submit value="GO"/>
</form>

in mmmm.jsp i set:
session.setAttribute("aaa","bbb");
System.out.println("my aaa="+session.getAttribute("aaa"));
response.sendRedirect("pppp.jsp");

in pppp.jsp
System.out.println("my aaa="+session.getAttribute("aaa"));

my result is:
aaa=bbb
aaa=null

why null??
Avatar of bloodredsun
bloodredsun
Flag of Australia image

Why are you writing to the tomcat logs with System.out.println? To write to the page you should use out.print()

This:
mmmm.jsp
<%
session.setAttribute("aaa","bbb");
out.print("my mmmm.jsp aaa="+session.getAttribute("aaa"));
response.sendRedirect("pppp.jsp");
%>

pppp.jsp
-----------
<%
out.print("my aaa="+session.getAttribute("aaa"));
%>

prints
--------
my aaa=bbb

which shows it works. What's the error?
Avatar of aaaaaa
aaaaaa

ASKER

the error come out when my pppp.jsp more than 270 line

and this only happen when i open with email!

u know what is mean?

<form action="http://localhost/mmmm.jsp" method=post>
<input type=submit value="GO"/>
</form>
if this is in a *.html, is work fine and i will get my aaa=bbb

but when i open by email, my aaa=null
Even if you do this

mmmm.jsp
------------------
<%
session.setAttribute("aaa","bbb");
out.print("my mmmm.jsp aaa="+session.getAttribute("aaa"));
System.out.println( "my mmmm.jsp aaa="+session.getAttribute("aaa") ) ;
response.sendRedirect("pppp.jsp");
%>

pppp.jsp
------------------
<%
out.print("in pppp.jsp my aaa="+session.getAttribute("aaa"));
System.out.println( "in pppp.jsp my aaa="+session.getAttribute("aaa") ) ;
%>


pppp.jsp outputs this in the browser
------------
in pppp.jsp my aaa=bbb


and the tomcat log output is
------------
my mmmm.jsp aaa=bbb
in pppp.jsp my aaa=bbb

Which shows that both work as they should...
Avatar of aaaaaa

ASKER

same i got null.

u know what i need to do?

i try to access my web click my a email.

please the notice is 'EMAIL'.

is working fine if i click from anyjfdkljfla.html
>> the error come out when my pppp.jsp more than 270 line
>>and this only happen when i open with email!
>>u know what is mean?

Sorry no. Could you explain a little more please? How do you "open with email"

I notice your form action is "http://localhost/mmmm.jsp". So you are working in the root directory and have changed the tomcat port to 80, is that correct?
Avatar of aaaaaa

ASKER

my testing.html
****************************
<form action="http://localhost/mmmm.jsp" method=post>
<input type=submit value="GO"/>
</form>
****************************
when i click 'GO', it point to http://localhost/mmmm.jsp, then redirect to
http://localhost/pppp.jsp, then show value: my aaa=bbb


____________________________________________________________
in my email.
*****************************
<form action="http://localhost/mmmm.jsp" method=post>
<input type=submit value="GO"/>
</form>
******************************
when i click 'GO', it point to http://localhost/mmmm.jsp, then redirect to
http://localhost/pppp.jsp, then show value: my aaa=null

Avatar of aaaaaa

ASKER

in my http://localhost/pppp.jsp page
**************************************
<%
out.print("my aaa="+session.getAttribute("aaa"));
...
....
...
..
.. totally 270 line here
%>
i look my extra 269 line i s no probluem.

but dun know why if open my html it work fine, but open my email cannot
Try this in mmmm.jsp:

<%
session.setAttribute("aaa","bbb");
out.print("my mmmm.jsp aaa="+session.getAttribute("aaa"));
System.out.println( "my mmmm.jsp aaa="+session.getAttribute("aaa") ) ;
RequestDispatcher rd = request.getRequestDispatcher("pppp.jsp");
rd.forward(request, response) ;
%>
Avatar of aaaaaa

ASKER

summary:

1)open by html, with pppp.jsp line 270
  fine

2)open by email, with pppp.jsp line 270
   null

3)open by html, with pppp.jsp line 1
   fine

4)open by email. with pppp.jsp line 1
   fine also
Avatar of aaaaaa

ASKER

my mmm.jsp aaa=bbb

org.apache.jasper.runtime.jspfactoryimpl internalgetpagecontext

sereve: exception initializing page context
java.lang.stackoverflowerror
Just to be clear, when you say open with email, do you mean open with web-based email like hotmail or opened with an email client like Outlook?

The 270 line problem may be the fact that compiled JSPs cannot be larger than 64K. This is because javac does not allow a single method to be larger than 64K and JSPs can be considered to be just on large method. But that should be caught on compilation. It can be worked around by breaking the page up into smaller subsections and using jsp:include to build a single bigger page.
Avatar of aaaaaa

ASKER

i open with outlook
>>org.apache.jasper.runtime.jspfactoryimpl internalgetpagecontext

This happens when the server can't get the session from the request

Try adding <%@ page session="true" %> to the top of mmmm.jsp

Just to be clear, when you say open with email, do you mean open with web-based email like hotmail or opened with an email client like Outlook?

The 270 line problem may be the fact that compiled JSPs cannot be larger than 64K. This is because javac does not allow a single method to be larger than 64K and JSPs can be considered to be just on large method. But that should be caught on compilation. It can be worked around by breaking the page up into smaller subsections and using jsp:include to build a single bigger page.
Avatar of aaaaaa

ASKER

i open with outlook
Does it work okay when you use a browser like Internet Explorer or Firedfox?
Avatar of aaaaaa

ASKER

oh thanks, this work
<%@ page session="true" %>

very thankyou, but can u explain why?
ASKER CERTIFIED SOLUTION
Avatar of bloodredsun
bloodredsun
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial