We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,267 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

javascript <pre> tag keep text format

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
2 Days
Discussion Span
1 Year Ago
Last Updated
5
Views
Question
Answered
softDeveloper
Junior Poster in Training
76 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

what exactly do you put in as input, and what do you expect as a result?

stultuske
Industrious Poster
4,379 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24

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..

softDeveloper
Junior Poster in Training
76 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

Fest3er
Posting Whiz in Training
243 posts since Aug 2007
Reputation Points: 51
Solved Threads: 35
Skill Endorsements: 0

Thank you so much!

Kind Regards!

softDeveloper
Junior Poster in Training
76 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by stultuske and Fest3er

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0713 seconds using 2.68MB