Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wrapping text & StringBuffer 1

Status
Not open for further replies.

AvaB

Programmer
Jun 23, 2004
16
0
0
CA
I have a StringBuffer object in B.jsp that collects various String objects passed from some A.jsp and displays it on the screen.

B.jsp:
Code:
String name_input = request.getParameter("name");
String address_input = request.getParameter("address");
String comment_input = request.getParameter("comment");

StringBuffer sb = new StringBuffer();
sb.append("Name: "+name_input);
sb.append("\n");
sb.append("Address: "+address_input);
sb.append("\n");
sb.append("Comments: "+comment_input);
sb.append("\n");

I am expecting the comments text to be multi-lined. My problem is that when my StringBuffer is displayed, the comments text is not wrapped and thus, runs all the way and over the end of the screen, displaying an unsightly horizontal scroll bar. I realize I can write a method that would parse the line and wrap it accordingly or change the format into table cells but I was wondering if there's already a package out there available that will provide such wrapping services for me?

Thanks.
 
From your mention of "A.jsp" and "B.jsp" I take it you are working with web applications.

Remember that JSP is just a scripting tool for generating text displayed in browsers in the form of HTML.
So "\n" will have no effect - as this is not a vaild HTML tag. The line break form for HTML is the tag "<br>".

So in short, you should replace your "\n" with "<br>".

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top