0

Dear all,

I'm passing a javascript String variable varname in a form inside a jsp to another page.

<form name="form1" action="nextpage.jsp" method="post ">
	<input type="hidden" name="varname" value="teste" />
    <input type="button" value="button" onClick="document.form1.varname.value = function(window);"> 
    <input type="submit" name="button" value="test1" />
</form>

When I get the String in the next page with:

<%String var=request.getParameter("varname");
%>

However, all the breaklines and whitespaces are gone when the page is displayed!

I tried using the <pre> </pre> tag but no improvements.

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by softDeveloper
0

Example of input:

Hello Hello 
Hi Hi Hi Hi


Hello Hello

Output I'm getting:

Hello Hello Hi Hi Hi Hi Hello Hello

I want to keep the same format when I call request.getParameter..

0
<%String var=request.getParameter("varname");
%>

However, all the breaklines and whitespaces are gone when the page is displayed!

I tried using the <pre> </pre> tag but no improvements.

You could try

<%String var="<pre>"+ request.getParameter("varname") +"</pre>";
%>

If that works, then you may be overwriting the PRE tags when you insert 'var' into the page's HTML.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.