• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

controlling display of data in jsp page

hi experts

I have a submit button in my jsp page and on submit it goes to the action class and displays the data. Displaying of data is
done in jsp and this peice of code in the jsp does that :

jsp code:


   if(session.getAttribute("logrepor") != null) out.println((String)session.getAttribute("logrepor"));


and i am setting it in the session in action class. like this

                session.setAttribute("logreportresult", lines.toString());

so when i hit submit button i see the data of -->   out.println((String)session.getAttribute("logrepor"));
in my jsp page
The problem is hereafter when ever the jsp page loads it shows me the data in  
 since it is set in session and its displaying it from session

is there any way i can change the code so that i can see -->  out.println((String)session.getAttribute("logrepor"));

only when i hit the submit button and not everytime the page loads

any responces greatly appreciated

  • 2
1 Solution
set it in request.

request.setAttribute("logreportresult", lines.toString());

and get it like

one more thing, if the page is getting load with the same action class.. u need to have different handling with the action class.
May be one action to handle the submit and the other action class to handle the page load. Something like dispatch action will work great in this scenario.
jaggernatAuthor Commented:
request works thanks

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now