This discussion is archived
2 Replies Latest reply: Jul 3, 2012 12:59 AM by gimbal2 RSS

Wrap a long text with paragraph spaces in JSP

918178 Newbie
Currently Being Moderated
Hi,

In Jsp, I wanted to display two paragrpahs like this.


THIS IS A TEST WITH DIARY TEXT. Para 1
THIS IS THE SECOND LINE.

A SINGLE BLANK LINE PRECEDES THIS TEXT,
TWO BLANK LINES FOLLOW THIS LINE.


THERE SHOULD BE TWO BLANK LINES BEFORE THIS ONE.

and a paragraph with long text to be displayed should be wrapped in the browser.

Para 2

THIS IS A TEST. THIS PARAGRAPH SHALL NOT HAVE ANY LINE SPACES IN BETWEEN.THE PARA BEGINS HERE.THE PARA BEGINS HERETHE PARA BEGINS HERETHE PARA BEGINS HERETHE PARA BEGINS HERETHE PARA BEGINS HERETHE PARA BEGINS HERETHE PARA BEGINS HERE.

The above paragraph should be wrapped while displaying in browser. I used

P STYLE="word-wrap:break-word;width:100%;left:0" but this is supporting the para 2 only and para1 is displayed without spaces in between the lines.

If I take the above tag from the jsp, then para 1 is supported and not para 2. Para 2 is displayed as long text.

Can anyone help me to find which will support two type of paragraphs in browser.

It should retain the spaces in between the lines
And also it should wrap the long text while displaying in browser.

I am not sure if this question is relevant in this forum. But it is since JSP I posted here.

Edited by: 915175 on Jul 2, 2012 10:10 PM
  • 1. Re: Wrap a long text with paragraph spaces in JSP
    EJP Guru
    Currently Being Moderated
    What you're doing is entirely contrary to HTML. The idea is that you mark up your paragraphs and the browser determines the layout, with some assistance from your CSS, but also depending on the user's choice of fonts, font size, window size, etc.

    Having said that, it is indeed possible to get your vertical line spacing the way you want, with suitable CSS.

    However, also, none of this is a Java question. The solution consists entirely of HTML markup and CSS styles.
  • 2. Re: Wrap a long text with paragraph spaces in JSP
    gimbal2 Guru
    Currently Being Moderated
    915175 wrote:
    I am not sure if this question is relevant in this forum. But it is since JSP I posted here.
    As EJP said, it is not and you could have easily reasoned that for yourself - there is nothing in your question that is about JSP programming. You could be creating a simple HTML page and still ask the exact same questions.

    And that's what I advise you to do: don't try to do this in a JSP directly, just edit a simple HTML file + a CSS file and make it work there first. On top of that install the Firefox browser and install the Firebug plugin - this allows you to change the styles of the page which will be instantly visible without having to reload the page, which is an immense help to fix styling problems. Otherwise you'll be making a change, reloading the page, making a change, reloading the page, etc. etc.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points