2

i've a hidden field value

<input type="hidden" id= "i1" name="h1" value="Request Recieved"/ >

i need the value to be read in another jsp file whose reference is mentioned in the current file.

i'm using out.println(request.getParameter("h1")); but its printing null..

technocrat
  • 701
  • 5
  • 13
  • 23
  • `i need the value to be read in another jsp file whose reference is mentioned in the current file.` can you show bit of code for this statement – jmj Nov 24 '10 at 11:50

1 Answers1

2

This will only work when you navigate to another JSP by a <form> which has this field embedded.

E.g. page1.jsp:

<form action="page2.jsp">
    <input type="hidden" name="foo" value="bar">
    <input type="submit">
</form>

And page2.jsp:

<p>Hidden value: ${param.foo}</p>

That's all. It won't work when you navigate by a link <a> or submit another form where the hidden field is not included.

(the ${param.foo} does effectively the same as out.print(request.getParameter("foo")), only in a less vintage and ugly manner. See also How to avoid Java code in JSP)

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555