.html" metho...">

Request.getParameter () does not work on jsp page using CQ

I have the code below

<div>
  <form action="<%= currentNode.getPath() %>.html" method="POST">
         <input type="text" name="test" id="test"/>
         <input type="submit" name="submitt" id="submitt" style="display:none;" /> 
     </form>
</div>

I am trying to get the value of a field test

<%
String name=request.getParameter("test"); 
out.println("value in the string"+name);
%>

But am I only getting a null value? What could be the problem?

+4
source share
1 answer
<form action="<%= currentNode.getPath() %>.html" method="POST">

You submit the form to the page html. And how can you get the result on the html page

your attribute form actionmust have the url of a servlet or other jsp in order to get the values ​​from the request.

Request is an implicit jsp object, not html.

For ex,

one.jsp:

        <form name="form1" action="two.jsp" method="POST">
          <input type="text" name="test" id="test"/>
         <input type="submit" name="submitt" id="submitt" style="display:none;" /> 
        </form>

two.jsp:

<%
String name=request.getParameter("test"); 
out.println("value in the string"+name);
%>

will print you the value in the request. rather, if you are trying to get the value on the same page without publishing it. can achieve this usingjavascript

+1
source

All Articles