0

My jsp page "view.jsp" has 5 values of cuid which I have turned all 5 into hyperlink. All these hyperlinks are getting redirected to the same page "modify.jsp" having input readonly field cuid. Now to get this readonly field's value, i am passing cuid from view.jsp to modify.jsp through hyperlink paramter "mcuid".

Now, the value is getting passed to the hyperlink fine. I confirmed this from my URL.

But I am unable to see this value in the cuid field in "modify.jsp". Below is the code I wrote for parameter passing.

1)view.jsp

    <td><a href="modify.jsp?mcuid=<%out.print(utils.getCuid().get(i));%>"><%out.print(utils.getCuid().get(i));%></a></td>

2)modify.jsp

<td>Cuid :</td>
<td><input type="text" name="cuid" value="<%request.getParameter("mcuid");%>" readonly /></td>
Cœur
  • 37,241
  • 25
  • 195
  • 267
user2889968
  • 35
  • 3
  • 10

1 Answers1

1

But I am unable to see this value in the cuid field in "modify.jsp".

Because, in <a> tag you made mistake, remove out.print() where you have assigned value to mcuid

<a href="modify.jsp?mcuid=<%out.print(utils.getCuid().get(i));%>"><%out.print(utils.getCuid().get(i));%></a>
                                ↑ 

Change to

<a href="modify.jsp?mcuid=<%=utils.getCuid().get(i);%>"><%out.print(utils.getCuid().get(i));%></a>  
                              ↑  

See also

Update answer to your comment

To get the value of variable mcuid in text box cuid

<input type="text" name="cuid" value="<%=request.getParameter("mcuid")%>" readonly />
                                        ↑ 

Now, read what is <%= %> in JSP?

JSP Expressions

A JSP expression is used to insert the value of a scripting language expression, converted into a string, into the data stream returned to the client. When the scripting language is the Java programming language, an expression is transformed into a statement that converts the value of the expression into a String object and inserts it into the implicit out object.

The syntax for an expression is as follows:

<%= scripting-language-expression %>

Note that a semicolon is not allowed within a JSP expression, even if the same expression has a semicolon when you use it within a scriptlet.

Community
  • 1
  • 1
Aniket Kulkarni
  • 12,825
  • 9
  • 67
  • 90