• Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaMail Web App and response.encodeUrl()

 
Bill Ostaski
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I understand the webapp demo, the messageheaders.jsp calls
ListMessagesTag to retreive information on the messages contained in the
opened folder.

searches the folder for messages without the DELETED flag set and makes the
total number of those messages the value of messageCount.
All this works well. I added a DeleteMessageServlet which sets the DELETED
flag to a message to be removed from the folder and that also works fine;
returning to messageheaders and showing all messages less the one with the
DELETED flag set.
My troubles began when I added response.encodeURL() references to the
webapp. Some users of this webapp have javascript turned off in their
browsers, so the webapp breaks due to NotLoggedIn. I believed the best fix
would be to include session tracking with response.encodeURL().
After adding the encodeURL() references, I get an
ArrayIndexOutOfBoundsException at
ListMessagesTag.getMessage(ListMessagesTag.java:140), which is the helper
method for retreiving messages in DoStartTag().
It looks like the DELETED flag is not being set, but I've verified it is
being set with:

in a jsp returned by DeleteMessageServlet.
Is the size of the Message array set each time ListMessagesTag is called or
is it cached somehow as a session attribute? How do I get ListMessagesTag to
see the new array size? Also, I have a DeleteSpamServlet which deletes a
varying number of messages, so I can't simply decrement messageCount by one.
Any insight is much appreciated.
Bill
 
Bill Ostaski
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still trying to discover why returning to messageheaders.jsp after
setting the DELETED flag on a message returns an ArrayOutOfBoundsException.
It seems like the messages array in ListMessagesTag is being cached somehow
and not reflecting the new number of messages in the folder without the
DELETED flag set.
One thing I noticed in the original webapp version was this setter method in
MailUserBean:
/**
* session setter method
*/
public void setSession(Session s) {
this.session = session;
}
Shouldn't (Session s) be (Session session) or the assignment be
"this.session = s"? I did this in my version.
I also notice that there are many imports declared in the original classes
that are never used. Is there a reason for these?
Other than these differences, the only behavior I can reproduce consistently
is that returning to messageheaders.jsp after setting the DELETED flag on a
message returns an ArrayOutOfBoundsException, but then hitting the back
button on the browser returns to messageheaders.jsp *without* that message
being displayed.
Instead of returning to messageheaders.jsp, I also tried going to a copy,
messageheaders2.jsp, and that worked as it should. However, trying the same
exercise a second time results in the same exception as before.
Again, any insight into this problem would be much appreciated.
Bill Ostaski
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!