This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

problem with session and refresh button  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I am new to JSP programming. I have a JSP page where i search database and the result's are displayed on the same page. I am also storing the displayed result in the session for printer friendly display upon user request.
After searching the database if i press the refresh button the number of records displayed on the page are multiplying by the number of refresh button pressed.
Is there any way i can stop the session to append the same results to the output every time press refresh button.
Thank's in advance
Ramu Vempati
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please post your code .
 
ramu vempati
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kripla,

...
......
<!---- jsp code starts here -->
<%

String submit = request.getParameter("submit");
String f_name = request.getParameter("fname");
String l_name = request.getParameter("lname");
String selectedOption = request.getParameter("selectOption");
String providedInfo = request.getParameter("text");
if (submit != null)
{

%>

<jsp:useBean id = "query_db" class="CNGI.NewInsert" scope="session" />
<jsp:setProperty name="query_db" property= "*" />
</jsp:useBean>

<%
query_db.connect();

if(submit.equals("search"))
{
query_db.enquiry(f_name, l_name);
String first = query_db.firstName;
String last = query_db.lastName;

if ( first == null || last == null )
{
%>

<font face="Arial, Helvetica, sans-serif" color="#0000FF"><b>Sorry
there are no records with<font color="#FF0000"> <%= f_name %> <%= l_name %></font>
in the Database.</b></font> <b>

<%
query_db.disconnect();
} else
{

query_db.query(f_name,l_name);
}
} else if(submit.equals("AdvanceSearch"))
{
if( selectedOption.equals("None"))
{
%>
<font face="Arial, Helvetica, sans-serif" color="#0000FF">
You have not selected an Option for Advance Search. Please select an Option to search .</font>
<%

query_db.disconnect();
} else
{
query_db.advanceSearch(selectedOption, providedInfo);
}
}

Vector data = query_db.getQuery();
session.setAttribute("printer", data);

int size = data.size();
int sizeOfRecord = size/9;

%>
</b>
<b> <font face="Arial, Helvetica, sans-serif" size="3" color="#0000FF"><u>There
are Total <font color="#FF0000"><%= sizeOfRecord %></font> Records for your
search:</u></font></b>

<p align="left">
<%
int i=0;

for(int k=1; k<=sizeOfRecord; k++)
{
...... ... under this there is code for presentation
Please let me know if u want all the code
Thank You
Ramu
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!