I have a jsp page which hyperlinks to another jsp page. If we click on "Update Preferences" from below shown image, then it opens the 2nd image:
Below is the code for the jsp shown in the 2nd image:
<body>
<center>
<div style="font-style:bold;font-size:30;color:black"> Data Platform - Monitor </div>
</center>
<BR><BR>
<%!
VoltDAOImpl voltDao = new VoltDAOImpl();
%>
<form action="dp_monitor.jsp" method="get" >
<table width="350" border="0">
<tr valign="Left">
<td><b>Client Acronym: </b> </td><td> <b> <input type="text" name="client_acronym" value="PEAKM"></b></td>
</tr>
<tr valign="Left">
<td><b>Sort By :</b></td>
<td>
<select name="sort_by">
<option selected="true" value="notional">notional</option>
<option value="arr_mid_slp">arr mid slippage</option>
<option value="order_qty">order qty</option>
<option value="liq_consmption">liq consmption</option>
<option value="arr_last_slp">arr last slippage</option>
<option value="ivwap_slp">ivwap slppage</option>
<option value="exec_qty">exec qty</option>
<option value="leaves_qty">leaves qty</option>
<option value="limit_px">limit px</option>
<option value="avg_px">avg px</option>
<option value="last_px">last px</option>
<option value="last_qty">last qty</option>
<option value="transact_time">transact time</option>
<option value="arr_mid_px">arr mid px</option>
<option value="ivwap_volume">ivwap volume</option>
<option value="ivap_px">ivap px</option>
<option value="arr_last_px">arr last px</option>
<option value="end_last_px">end last px</option>
</select>
</td>
</tr>
<tr valign="Left">
<td><b>Algo: </b> </td>
<td>
<select name="algo">
<option selected="true" value="">ALL</option>
<%
try{
List<String> algo_list= voltDao.getDistinctAlgos("PEAKM",voltDao.client);
for(String algo : algo_list )
{
out.println("<option value=\""+algo+"\">"+algo+"</option>");
}
} catch(Exception e){System.out.println( " error in getting algos" ); }
%>
</select>
</tr>
<tr valign="Left">
<td><b>ListId: </b> </td>
<td><select name="listid">
<option selected="true" value="">ALL</option>
<%
try {
List<String> list_id__list= voltDao.getDistinctListID("PEAKM",voltDao.client);
for(String list_id : list_id__list )
{
out.println("<option value=\""+list_id+"\">"+list_id+"</option>");
}
} catch(Exception e){System.out.println( " error in getting listids" ); }
%>
</select>
</td>
</tr>
<tr valign="Left">
<td><b>Refresh : </b> </td>
<td>
<select name="refresh">
<option value="1">1 sec</option>
<option value="3">3 secs</option>
<option value="5">5 secs</option>
<option value="10">10 secs</option>
<option value="15">15 secs</option>
<option value="30">30 secs</option>
<option value="45">45 secs</option>
<option value="60">1 min</option>
<option value="120">2 min</option>
<option value="180">3 min</option>
<option value="240">4 min</option>
<option value="300" selected>5 min</option>
</select>
</td> </tr>
<tr><td></td> </tr>
<tr><td></td> </tr>
<tr><td></td> </tr>
<tr> <td><button type="submit">Update</button></td>
<td><button type="reset">Clear</button></td>
</tr>
</table>
</form>
</body>
So, everytime I select a preference, say for "Refresh
" from the dropdown, I select 5 secs
, then click on Update
, so it goes back to the first jsp (the first image shown above). Now when I again click on "Update Preferences
" then it shows the default selected value of 5 mins
and not 5 secs
. How do I get the preferences that were selected before to show everytime I click on Update Preferences
?
UPDATE: I added this to my 2nd jsp:
<%
String refreshValue = request.getParameter("refresh");
if(refreshValue==null){
refreshValue = "60";
}
%>
<td><b>Refresh : </b> </td>
<td>
<select name="refresh">
<option value="1" <% if(refreshValue.equals("1")) { %> selected <% } %>>1 sec</option>
<option value="3" <% if(refreshValue.equals("3")) { %> selected <% } %>>3 secs</option>
<option value="5" <% if(refreshValue.equals("5")) { %> selected <% } %>>5 secs</option>
<option value="10" <% if(refreshValue.equals("10")) { %> selected <% } %>>10 secs</option>
<option value="15" <% if(refreshValue.equals("15")) { %> selected <% } %>>15 secs</option>
<option value="30" <% if(refreshValue.equals("30")) { %> selected <% } %>>30 secs</option>
<option value="45" <% if(refreshValue.equals("45")) { %> selected <% } %>>45 secs</option>
<option value="60" <% if(refreshValue.equals("60")) { %> selected <% } %>>1 min</option>
<option value="120" <% if(refreshValue.equals("120")) { %> selected <% } %>>2 min</option>
<option value="180" <% if(refreshValue.equals("180")) { %> selected <% } %>>3 min</option>
<option value="240" <% if(refreshValue.equals("240")) { %> selected <% } %>>4 min</option>
<option value="300" <% if(refreshValue.equals("300")) { %> selected <% } %>>5 min</option>
</select>
And this to my 1st jsp (dp_monitor):
<input type="hidden" name="refresh" value="<%=request.getParameter("refresh")%>">
<%String refresh = request.getParameter("refresh");
if( ("".equals(refresh)||refresh==null ) )
refresh="4000";
// Set refresh, autoload time
response.setIntHeader("Refresh", Integer.parseInt(refresh));
// Get current time
Calendar calendar = new GregorianCalendar();
String am_pm;
int hour = calendar.get(Calendar.HOUR);
int minute = calendar.get(Calendar.MINUTE);
int second = calendar.get(Calendar.SECOND);
if(calendar.get(Calendar.AM_PM) == 0)
am_pm = "AM";
else
am_pm = "PM";
if(hour == 0)
hour = 12;
String CT = hour+":"+ minute +":"+ second +" "+ am_pm;
out.println("Last Refresh Time: " + CT + "\n");%>
But, it's whenever I select some value from "Update Preferences", then click on "Update", and then come back, it is taking refreshValue
as null
only, and hence showing 1 min
only as selected. What to do?