textArea for RTF input/output

Posted on 2006-05-22
Last Modified: 2006-11-18
I'm building a web app using Struts/JSP.

I need to provide textArea where users can format their input.  I'd like to have the buttons with formatting functions such as font, bold, italic, etc.
When user clicks submit, I need to save the RTF formatted string in database.
For example, if user enter "hello" and format it italic...
then, I need to grab the string

{\rtf1\ansi\ansicpg949\deff0\deflang1033\deflangfe1042{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit;}\viewkind4\uc1\pard\i\f0\fs20 hello\i0\par

( \ is backslash )

Also, when I pull this from database, I need to display it as italic "hello"
Any ideas/suggestions? Thanks.

Question by:derilische
    LVL 14

    Expert Comment

    by:Tommy Braas
    Use a javax.swing.JEditorPane with a javax.swing.text.rtf.RTFEditorKit.
    LVL 14

    Expert Comment

    by:Tommy Braas
    You can then call getText() on the JEditorPane to get the RTF content, and conversely setText() to set the RTF content of the component.

    Author Comment

    I'm using JSP/Struts, and don't want to use applet.  
    Is there any other way?
    LVL 14

    Accepted Solution

    >> I'm using JSP/Struts, and don't want to use applet.  
    You mean you're using HTML.

    >> Is there any other way?
    Sure, JavaScript and CSS.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now