Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

hidden variable null in jsp why?

  Asked By: Lewis    Date: Mar 20    Category: Java    Views: 2212
  

I am getting null values in jsp i have debuged the code as well and the variable
contains value but not ale to get it from calling jsp here is code

/*
* Where hidden varibale is setting value
*/

<% path = list[i].getPath();%> // shows vakue here

<input type="hidden" name="path" value="<%= path%>">
<a target="_blank" href= "../../jsp/RequestHandler.jsp" > Preview</a>

/*
* When anothe jsp is called them
*/
path = request.getParameter("path");

if (path != null){
path = "../../"+path;
response.sendRedirect(path);
}
else if (path == null){
out.print("<h3>path not found</h3>");
}

it always show path not found and if i am not forwarding request then it shows
null
like this

out.write("path received is = "+ path);

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Mercedes Andrews     Answered On: Mar 20

you can set the path variable  in the session and get it from the
RequestHandler page, since when the form is submited only, the hidden
variables are passed to next page, not for the link. or you may give the
link as

">preview

 
Answer #2    Answered By: Fuzairah Neeman     Answered On: Mar 20

Please note that you can only use - request.getParameter("name_of_var") once.
After that it will return null.

What I suggest is that, make two very simple pages just to pass a variable  and
try to catch it at other end. As you have not provided complete code, I think
you are missing something.

 
Didn't find what you were looking for? Find more on hidden variable null in jsp why? Or get search suggestion and latest updates.




Tagged: