Results 1 to 5 of 5
  1. #1
    vishnukumar is offline Member
    Join Date
    Jun 2009
    Posts
    3
    Rep Power
    0

    Default getting java program from textarea

    Hi,

    I have a text area in my web page. Where I wrote some java program and submitted the form. While I use request.getparameter("textarea_name"); I got the text, but the break(for the next line) is not fetched.

    For example,

    In textarea I wrote,

    class Add{
    public Add(){
    int a;
    int b;
    }
    }

    But, I got in the request as,

    class Add{public Add(){int a;int b;}}

    I need to get the same pattern.

    Please, help me to achieve.

    Thanks.

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    804
    Rep Power
    6

    Default

    Like this java-forums u embed the string in code tag and try .
    Ramya:cool:

  3. #3
    vishnukumar is offline Member
    Join Date
    Jun 2009
    Posts
    3
    Rep Power
    0

    Default

    Hi,

    Thanks for your reply.

    Let me know in detail of "string in code tag ". I can't understand.



    -vishnukumar

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    804
    Rep Power
    6

    Default

    Hi Vishnu,
    I have given a sample code below.Whatever you are inputting in a textarea just display it in textarea embedede with CODE tag in html.I have given a sample code.Just run it and see.


    Java Code:
    <form method ="get" action="test.jsp">
    <textarea name ="codeTextArea"  > </textarea>
    <input type= "submit"> 
    
    <%
       String output = request.getParameter("codeTextArea");
       if((output != null) || output !="" || output.length() > 0)
       {
    %>
          <textarea name ="outputCode"
    	  value<%="<CODE>"+request.getParameter("codeTextArea")+"</CODE>"%>
    	  </textarea>
    <%
       }
    %>
    Ramya:cool:

  5. #5
    vishnukumar is offline Member
    Join Date
    Jun 2009
    Posts
    3
    Rep Power
    0

    Default

    Hi,

    I got exactly, what I expect with the code. But, What I need is?. I am getting values from the textarea and storing it to the database, then retrieving from the database and displaying in the web page. I am using MySQL DB. While displaying in the web page, all carriage return are absent. I am getting the values in a single line.

    I think, its better, where carriage return are replaced with "\n".

    Please, guide me.

    Thank you


    - Vishnukumar

Similar Threads

  1. TextArea with Unicode
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 04-16-2008, 10:53 PM
  2. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  3. TextArea Bug?
    By Soda in forum New To Java
    Replies: 2
    Last Post: 12-07-2007, 12:37 PM
  4. Replies: 0
    Last Post: 10-04-2007, 09:33 PM
  5. textarea
    By ubuntu in forum AWT / Swing
    Replies: 4
    Last Post: 05-12-2007, 09:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •