You have a couple of choices. One is regular expressions. The other is to create a parser that recognizes and assigns meaning to tokens in the html text.
I would suggest doing a google search on Java + Regular Expression.
If you do that, the second link in the list is this one. http://java.sun.com/docs/books/tutorial/essential/regex/
Start reading.
PS.
> Hi,
>
> Remove the < > from the tag. String has
> lot of methods. Use split and startswith methods to
> remove the <> or use regular expression.
>
> bye for now
> sat
Hello you mean that if i remove only the <> from
it work like a carriage return ?
Don't bother, unless you know the ONLY html tag is
.
With regular expression, you have to list each TAG you want to replace,
and list what you replace it with.
Regular expressions do not magically turn HTML into plain text.
Note, as already suggested by others, if the string LITERALLY
starts with the 6 characters "<html>", then most Swing text components (JTextField, JTextArea...)
will render it as HTML (you know, with bold, itatic, hyperlink, linebreak, etc.)
Java 1.5 only supports up to about HTML 3.x, and has very
poor support for CSS. I don't know if the situation improves in Java 1.6 or not.
>
> It's text to display in jsp
>
Yike! I didn't notice you wrote this.
Oh, okay. So it is text that will be printed by jsp into a user's browser.
In this case... then... what's the problem?
will SHOW UP AS a line break when the user visits your JSP page.
<b>abc</b> will SHOW UP bold when the user visists your JSP page.
etc.
> Don't bother, unless you know the ONLY html tag is
>
.
> With regular expression, you have to list each TAG
> you want to replace,
> and list what you replace it with.
> Regular expressions do not magically turn HTML into
> plain text.
>
> Note, as already suggested by others, if the string
> LITERALLY
> starts with the 6 characters "<html>", then most
> Swing text components (JTextField, JTextArea...)
> will render it as HTML (you know, with bold, itatic,
> hyperlink, linebreak, etc.)
>
> Java 1.5 only supports up to about HTML 3.x, and has
> very
> poor support for CSS. I don't know if the situation
> improves in Java 1.6 or not.
The string doesnt start with "<html>" and its not for using with swing.
>
> It's text to display in jsp
>
Yike! I didn't notice you wrote this.
Oh, okay. So it is text that will be printed by jsp into a user's browser.
In this case... then... what's the problem?
will SHOW UP AS a line break when the user visits your JSP page.
<b>abc</b> will SHOW UP bold when the user visists your JSP page.
etc.
> Oh, okay. So it is text that will be printed by jsp
> into a user's browser.
> In this case... then... what's the problem?
>
will SHOW UP AS a line break when the user
> visits your JSP page.
> <b>abc</b> will SHOW UP bold when the user visists
> your JSP page.
> etc.
I wish it was working like this but it doesnt that is why i m posting.
I have a class that has a string, then i m getting the string and get it in my jsp but on the browser its showing like it is written in the class and not with a carriage return.
You need to provide more info.
If it is emitted in a normal context, then
will show up as line break by the browser.
But if it is emitted inside a <pre>..</pre>, then
will show up as
. Etc.
Also, you can DEBUG this step-by-step.
First, use your browser, click "View Source", and see what your JSP is spitting out.
If it is spitting out
, then it SHOULD show up as line break.
I suspect it is spitting out & lt ; br & gt ; instead (due to how your code prints it...).
If that is the case, then you go 1 step in, and look at the printing code, etc. etc.
etc.
[nobr]In my class :
objectif.setIntroductionVisuelGeneral("Le prix des obs鑡ues varie en fonction de la nature des prestations, le co鹴 moyen est d'environ 2 700 €. <br>A cela, s'ajoute le prix de la concession qui varie en fonction de l'emplacement du caveau, de son nombre de places, de sa surface et de la dur閑 de la concession (entre 700 et 7 000 €).");
In my jsp, with struts tag :
<tr>
<td>
<bean:write name="objectifSelectionne" property="introductionVisuelGeneral"/>
</td>
</tr>
I' m having problems with the
wich shows up in the browser as
and with the euro sign wich shows up as ?
I tried to replace the
and euro sign in my string with some ascii hexadecimal characters but its not working so i dont know how can i can i do to convert it[/nobr]
I asked you already: what does it output in the browser?
Use your browser, and click View Source, then paste the HTML text
corresponding to "Le prix des obsques varie en fonction de
la nature des prestations, le cot moyen est d'environ 2 700 .
A cela, s'ajoute le prix de la concession qui varie en fonction
de l'emplacement du caveau, de son nombre de places, de sa
surface et de la dure de la concession (entre 700 et 7 000 )"?
You're still misunderstanding me.
Let me be much more explicit:
1) Load your web browser.
2) Use the browser to visit your JSP page
3) You see that the browser is showing "
". Bad!
4) Right click on the page
5) Click ViewSource
6) You should see a LARGE page of text, like
<html>
<head> ... </head>
...
...
TheMessage with
in it
...
</html>
7) Now, for SOME reason, your browser REFUSE to show line break.
The reason is IN the html code.
Look at it.
Remember, the browser DOES NOT care where the html came from.
It could have come from a static page, or from a JSP/ASP/PHP, it doesn't matter.
Something in the HTML is INCORRECT, and it causes
to show up as
.
8) So, figure it out. Once you figure out what's wrong with the HTML,
you can go back, and see which line corresponds to it, which function
and which setting caused it. Then you can start your real debugging.
By default, <bean:write> encodes characters that are considered "special" in html. Add the attribute filter="false"
<bean:write name="objectifSelectionne" property="introductionVisuelGeneral" filter="false"/>
>
> By default, <bean:write> encodes characters that
> are considered "special" in html.
>
Ah, that sounds like it's exactly the source of the problem.
It will replace < with & lt ;
And replace > with & gt ;
And it is something that the OP could have confirmed
by ViewSource of the webpage, and see & lt ; br & gt ; instead of
(just like I said!!!)
This OP is driving me crazy.