Showing posts with label JSP. Show all posts
Showing posts with label JSP. Show all posts

Monday, June 21, 2010

Accessing a string variable which is in java file from javascript via jsp page

In java file:
Random random = new Random();
String ranLong = String.valueOf(random.nextLong());
session.setAttribute("hiddenvalue", ranLong);// this will sets the ranLong value in to the hiddenvalue
//ranLong variable contains some 10 digit number

In jsp file:
<%
String hiddenvalue1 = (String) session.getAttribute("hiddenvalue");
%>
now send this 'hiddenvalue1' to javascript
<body onload="setValue('<%= hiddenvalue%>')">

In javascript file:
function setValue(val){
document.getElementById("tf_CheckValue").value = val;
}

Tuesday, May 18, 2010

Clearing Browser Cache

<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"></meta>
<meta content="no-cache" http-equiv="Cache-control"></meta>
<meta content="no-store" http-equiv="Cache-control"></meta>
<meta content="no-cache" http-equiv="Pragma"></meta>
<meta content="0" http-equiv="expires"></meta>

<%
            response.setHeader("Cache-Control", "no-cache");
            response.setHeader("Pragma", "no-cache");
            response.setDateHeader("Expires", 0);
            response.setHeader("Cache-Control", "no-store");
%>