Re: save control characters in a session object
From: Collin VanDyck (thehoppocket_at_yahoo.com)
Date: 02/23/04
- Next message: GaryM: "Re: JAVAMAIL - IMAP Connection Failure: "* BYE disconnecting""
- Previous message: Alex M: "struts javascript validator message problem"
- In reply to: Andreas Bauer: "Re: save control characters in a session object"
- Next in thread: Andreas Bauer: "Re: save control characters in a session object"
- Reply: Andreas Bauer: "Re: save control characters in a session object"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 23 Feb 2004 19:58:45 GMT
> I want to make a little preview before sending the information to the
> database. The text should be shown the same way the user entered into
> the form.
> (jsp)
> String ueberschrift = null, untUeber = null, text = null;
> java.util.HashMap hm = (java.util.HashMap)
> session.getAttribute("articleText");
> ueberschrift = (String) hm.get("ueberschrift");
> untUeber = (String) hm.get("untUeber");
> text = (String) hm.get("text");
>
> Not the best way I guess, but I'm not that experienced in
> Servlet programming yet.
Ah, so in creating the preview for the user, your newlines are getting
"deleted" in the page? In other words, the text all runs together?
If in your JSP you are showing the fields like this:
<p>
field one: <%= ueberschrift %>
field two: <%= untUeber %>
...
</p>
Then the HTML page this produces will not care about any newlines in your
strings. One way to get around the newline problem would be to, when you
are displaying the strings, replace all "\n" characters with "<br/>". This
will create the newlines for you in HTML.
A better solution might be to wrap your formatted text with <pre>...</pre>
tags. This attempts to preserve formatting as much as possible when
displayed in the browser.
-Collin
- Next message: GaryM: "Re: JAVAMAIL - IMAP Connection Failure: "* BYE disconnecting""
- Previous message: Alex M: "struts javascript validator message problem"
- In reply to: Andreas Bauer: "Re: save control characters in a session object"
- Next in thread: Andreas Bauer: "Re: save control characters in a session object"
- Reply: Andreas Bauer: "Re: save control characters in a session object"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|