Reputation: 513
So in my Action class I have the following code.
public ActionForward detailsForUploadForm(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
try {
response.setHeader("Cache-Control", "no-store");
response.setHeader("Cache-Control", "no-cache"); // HTTP 1.1
response.setHeader("Pragma", "no-cache"); // HTTP 1.0
response.setDateHeader("Expires", 0); // prevents caching at the
// proxy server
request.setAttribute("filePath", filePath);
} catch (Exception ex) {}
And in my jsp file, I have the following
<html>String path = (String)session.getAttribute("path");
String filePath = (String)request.getAttribute("filePath");</html>
<form> <table>
<input type="hidden" name="filePath" id="filePath" value="<%=filePath%>"/>
</form>
</table>
The problem is, I am getting the value in my java class but in my jsp file i am getting the value as null.
Upvotes: 2
Views: 7179
Reputation: 2417
<html>String path = (String)session.getAttribute("path");
String filePath = (String)request.getAttribute("filePath");</html>.
What is this code ? You intended to write a java code inside scriptlet <% %>
, but you have written in inside <html>
tag. That won't set any variable in JSP. Instead this code will be displayed as it is on your page as text.
If you want to access request attribute in JSP, best way would be Expression language. Also you won't need above code in scriptlet.
Just use ${filePath}
<input type="hidden" name="filePath" id="filePath" value="${filePath}"/>
Upvotes: 0
Reputation: 21
if you using the struts to display the values then use this for display
<s:property value="%{#request.AttributeName}" />
Upvotes: 1