Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with session and refresh button  RSS feed

 
ramu vempati
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
 
Kripal Singh
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!