Java html question

Hi there,
I have tried to find this answer in google news and web search but with no luck.
I built a servlet to generate html for a webpage. I copy and paste text into a text box, and would like the java servlet to be able to find the end of a paragaph and generate the necessary html code to reflect the end of the paragraph - ie, </p> or 2 <br>'s.
Else, I have to do this manually which is very time consuming. There must be a way to do it in code since forum softwares do it.
Thanks in advance for any help.
E.

If you have the text in a string, you can use
regular expressions with replaceAll() to replace
a \n into a <br> or an empty line with </p><p>.
text.replaceAll("^$", "</p><p>");
text.replaceAll("\n","<br>");
More about regular Expressions See
http://www.regular-expressions.info/index.html

Similar Messages

  • How to make a horizontal line in java html browser?? without hr

    I use java html browser
    I want to make a black horizontal line
    the <hr> line is not good
    for my customer it seems that there is a double spacing in this case
    I tried to write
    <td style = "BORDER-BOTTOM: 1px solid #000000"> ...
    but it does not work
    I suppose this style is not supported by the default StyleSheet
    I tried to write
    <td bgcolor="black" height=1>
    but the table has all rows with equal sizes
    therefore the real height is too big
    Please help me
    I tried to write
    <table border="1">... </table>
    even in this case I have table without any border

    Hi,
    the best way might be to use a blind table with all cells set to have a border on the bottom. The problem is that the standard Java runtime does not render such setting automatically. There is plenty of work involved to adapt it and still it then would work only in the adapted version and not the standard runtime environment.
    Anyway, you can find a working example of how to accomplish individual borders around table cells in open source application SimplyHTML at http://www.lightdev.com/dev/sh.htm
    Ulrich

  • Flash/java remoting question

    Hi,
    i'm new to flash remoting and am finding using it with java
    quite troublesome. I've also found using the FileReference class
    troublesome if you use java. my question is can you somehow tie the
    remoting functionality to the FileReference.upload method
    fucntionality??
    thanks in advance

    I will use the program with photo detector to test
    the response time of the LCD screenWhy Java?I second that. With a test like that, you want to reduce the experiment down to a single variable, in this case the lcd response time. Using a java program to feed the monitor input introduces a second variable, the response time of the program. The java program's timer may not be exact, the components may not be repainted completely quickly enough, etc. If this is just for your own amusement, maybe that doesn't matter, but if you want your results to have any reliability, you'll need a more accurate and controllable input source.

  • Difference between Analyzer Java & HTML Client

    Hi,Does anyone know all the differences between Analyzer Java & HTML Client.A couple of diffence I noticed are:1. HTML Client doesn't support Linked Reporting Objects (LRO)2. HTML Client doesn't seem to support Navigate functionality in Java client.Are there any more differences ?TIA.

    http://download.oracle.com/docs/cd/E11882_01/install.112/e10876/toc.htm
    Pertains to the client installation.
    This guide describes how to complete a default installation of Oracle Database Client in a new Oracle home directory. It describes how to perform one of the following installation types:
    Instant Client: Enables you to install only the shared libraries required by Oracle Call Interface applications that use the Instant Client feature. This installation type requires much less disk space than the other Oracle Database Client installation types.
    Instant Client includes Instant Client Light. You may want to use this version of Instant Client if your applications will generate error messages in American English only. The advantage of using Instant Client Light is that it has a smaller footprint than regular Instant Client: its shared libraries, which your applications must load, are only 30–32 MB as opposed to the 216 MB that regular Instant Client uses. Hence, your applications use less memory.
    Administrator: Enables applications to connect to an Oracle database on the local system or on a remote system. It also provides tools that let you administer an Oracle database.
    Runtime: Enables applications to connect to an Oracle database on the local system or on a remote system.
    Custom: Enables you to select individual components from the list of Administrator and Runtime components.
    "

  • Can I post here(Acrobat Windows) Java Script questions here?

    Hello
    Can I post here(Acrobat Windows) Java Script questions here? If not, wht is the correct forum?
    THank you

    Back up and down to Acrobat Scripting. Bot Windows and MacIntosh Acrobat versions use the same JavaScript.
    If you are using LIVECYCLE DESIGNER use their forums. The JavaScript syntax and objects are different in LIVECYCLE DESIGNER!

  • Java/HTML/Loop Question

    Hiya,
    I wasn't too sure where I should post this so let me know if its in the right place.
    Basically I am completing an online voting system using servlets. I have all the features working correctly except for one. I am totally dumstruck as to what I should put in the below ****** gap.
      out.println("<form name = vote action=ballotServlet method= POST>" +
                                "<TABLE border = 1 cellspacing = 3>" +
                                "<tr><th>Name</th><th>Description</th><th>Party</th><th></th></tr>");
                        ArrayList all = c.allCandidates;
                        for (int i = 0; i < all.size(); i++) {
                            Candidate value = (Candidate) all.get(i);
                            out.println("<tr><td>" + value.getName() + "</td>" +
                                    "<td>" + value.getDescription() + "</td>" +
                                    "<td>" + value.getParty() + "</td>" +
                                    "<td><input type=radio name=vote value= ****** ></td></tr>");
                        out.println("</TABLE>" +
                                "<p><input type=submit id=submitVote value=Submit Vote>" +
                                "</BODY></HTML>");
                        out.close();Basically, I need the value from whatever is produced in that loop (the value of the radio button) but if I assign it to a value such as value.getName..it just reads it out as this String rather than the actual value. I have tried to assign it to a seperate value also but it just doesn't work.
    Does anyone have any ideas?
    Thanks,
    welsh-diva87

    I'm not sure this is something we can answer for you. It's a design decision. You seem to be asking "How can I identify which candidate was selected when the form gets posted back to the server?"
    This identifier is whatever you want it to be. It should be some unique value for each candidate in your list, and something that won't cause problems when being URLEncoded. The name may work, in which case you could put value.getName() in your space. If that doesn't meet your needs, then use something else, even an arbitrary id string for each candidate.
    Btw, the HTML you are generating is very wrong. Your attribute values need to have quotes around them in the response. If you're in java code you could print it like this:
    out.println("<form name=\"vote\" action=\"ballotServlet\" ...{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Java Regex Question (HTML Tokenizing

    Hello
    I would like to tokenize a HTML Page into its html tags and could not find any working expression. I tried it with:
    <[.]*>
    and for all input fields:
    <(INPUT.*)>
    But it doesn't find anything either or it findes anything.
    Can somebody help me?

    </?\S+?[\s\S+]*?>
    "/?" means: "/" can be there but doesnt have to
    "\S" means: every character which isnt a whitespace
    "+" means: look for the previous character if it is there at least one time.
    the "?" after the "+" means: look only for as few of the previous characters as needed to fullfill the regex.
    thats why <adf>sdf> isnt found because <adf> is the shortest string that fullfills the regex.
    "[]" means: treat everything inside the brackets as one term
    "\s" means: look for a whitespace
    "*" means: the previous character (which is the term inside the brackets) can be there as many times as it wants, even zero times
    "*?" is like "+?"

  • Simple Java Sound Question...

    Can I draw waveforms while capturing data? If yes, how. If no, why.
    Thanks. I need the answer ASAP, please help.

    Hi nfactorial,
    Can I draw waveforms while capturing data?If you would like to do that in Java you would need to know about how to use the Java language in general and especially about the Java Sound and Java2D APIs.
    If yes, how.It would be too much to explain to answer such a general question. A general answer is, you need to use the Java Sound API to capture the data for which a waveform should be drawn. The Sound API delivers data as a stream of bytes typically encoded in pulse coded modulation (PCM) format. The data stream has digital samples each representing a level of sound pressure for a certain point in time. The stream of samples in the amplitude/time domain need to be transformed to a spectrum of samples in the amplitude/frequency domain, i.e. a number of PCM samples need to be mapped to the frequencies that should be displayed. This is done with the fast fourier transformation algorithm. Each set of amplitude/frequency values can then be displayed as a waveform by using some line drawing logic. The entire process would need to run constantly, i.e. as bytes are received from the sound data stream transformation and drawing is triggered.
    Related readings:
    Java Tutorial
    http://java.sun.com/docs/books/tutorial/
    Java Sound Documentation
    http://java.sun.com/j2se/1.5.0/docs/guide/sound/index.html
    Java Sound API Programmer's Guide
    http://java.sun.com/j2se/1.5.0/docs/guide/sound/programmer_guide/contents.html
    Java Sound Resources
    http.//www.jsresources.org
    Java 2D Graphics Tutorial
    http://java.sun.com/docs/books/tutorial/2d/index.html
    Wikipedia on fast fourier transformation
    http://en.wikipedia.org/wiki/Fast_fourier_transform
    HTH
    Ulrich

  • Javascript/HTML question

    I've been teaching myself Java on and off for the past couple years with the help of these forums and other tutorials. Now I've decided to take on a project that requires the use of HTML and Javascript and I can't seem to find the information I need. I was hoping that somebody from these forums could either answer my questions and/or point me in the right direction to find the answers.
    The project is simple. I created an HTML window with an inputTextArea, an outputTextArea, and two buttons (Submit and Reset). When Submit is pressed I need the program to take the text from inputTextArea one line at a time, check the indexOf a string, and add tags at the beginning and end of the string if it meets certain criteria before appending it to outputTextArea.
    I can (and have) written this very easily in Java but I can't seem to find the methods I need in Javascript. In java I use a java.io LineReader to read the inputTextArea.getText() one line at a time and then make the changes as needed. I actually can't even find a tutorial in Javascript that can explain how to take the text from inputTextArea and print it into outputTextArea.
    So the main thing I need to know is how to read one line of text at a time from the inputTextArea. I think I can figure the rest out.

    That was actually my original thought when I started on the Java version of the program but I couldn't figure out how to enter the the carriage return in as a variable to be indexed. So it wasn't until after I found the LineReader that I was able to complete the Java version.
    Is there some way to enter the carriage return in as a searchable variable?

  • Bundling all java,html and even images in a jar file

    Hi All,
    When i bundle all my application .java files in a jar along with manifest i give something as,
    jar -cvf Name.jar manifest.txt *.classMy question is if i want to bundle even couple of HTML and even some images like(jpg,png..etc)..How should i do that???
    Thanks in advance.
    regards,
    Viswanadh

    Follow the instructions here:
    [http://java.sun.com/docs/books/tutorial/deployment/jar/index.html]
    Note that if you want to run the html. it must be outside of the jar, not in it.

  • Java server question for sockets

    Hello,
    I have a C/C++ server which works fine to communicate to Flash, but I want to use Java + Eclipse over text file editing and makefile headaches of C/C++. This will be a big project that requires organization of code, garbage collection, and nice arrays so Java is a smart choice over C/C++. I'm just hung up trying to get an echo server...
    I found this echo server code: http://pastebin.com/thiQtEz5
    It will receive data coming in, but when it sends echo data out, I don't read it in AS3(Flash). If I use a C/C++ echo server, I get data in and echo data out so I can read it in AS3(Flash).
    It seems like most Java examples use similar code, and I find them reading in, but not communicating from echo out to AS3(Flash) read in.
    If anyone has any suggestions, I'm interested. I'm new to Java, but I bet I can do cool things with it if I could get sockets working.
    ,James
    PS if it helps, I also cannot use my C/C++ echo client to send data to the Java echo server... It simply doesn't read data if there is any content. If I send a null string, it understands a null string came in though.
    PSS: Is this the right forum for AS3 questions, I couldn't find an AS3 forum

    Hi,
    It seems that you are trying to display JSP pages. All Application servers that I am aware of convert JSP pages to a servlet and use that servlet to generate a Html page. Therefore it seems that the answer to your question is Yes!

  • Java Novice Question (don't shoot me)

    Hello,
    I wanted to ask a very novice question, that I can't seem to find an answer to.
    I have Eclipse IDE for Java, and I also have Visual Studio (C#). In Visual Studio, you can create a application project, drag and drop a button, then double click the button tod be taken to the code behind the button, that's where you insert your code on what you want the button to do once you click it.
    Is there something similiar to that in Java (I know there must be), where you can drag and drop textboxes, buttons, etc., and then double click those items to code?
    Any light that ANYONE can shed on this would be highly appreciated!
    Thanks!
    Waleed

    waldo33 wrote:
    Okay, thank you for the patience! I will download the "kitchen sink" version, and by that I assume you mean the biggest Netbeans file :)Yeap.
    Regarding "building a website"...by that I mean...I want to build a simple website, which incorporates (MySQL which I already installed, installed the ConnectorJ, etc.), a front end (JSP would be nice, which i'm learning), and ofcourse the backend Java coding.Right. Thats not what I got from your first message. I thought your were simply after create a rich client (I.e. Java Swing). Creating a web site is a more advanced topic. I don't know of any GUI editors for it, but then I don't do it (I half expect someone to post IntelliJ IDEA now). But we are just talking HTML and lots of HTML editors exist.
    I don't care how easy the website, as long as I can learn (on a basic level). You are going to have to look up tutorials on Java EE.Personally I don't think this is a "new to java" topic.
    (Scary, covers all of JEE) [The Java EE 5 Tutorial|http://java.sun.com/javaee/5/docs/tutorial/doc/]
    Re: "Right tool for right job"...are you suggesting that I have Eclipse for coding Java, and NetBeans for more GUI apps and developement?The UI for rich clients I do in NetBeans. Everything else I do in Eclipse. But this is just me, and I'm luck enough to be able to dictate tool chains.

  • Java HTML Renderer

    Hi all,
    I wonder if any one could help me.
    I have recently decided to undertake the writing of an HTML browser for a project, I have been researching the idea and come to a pretty deadish sort of end.
    My research has taken me to various other browsers in java - Warrior, XBrowser etc. All have an HTML rendering engine create specifically for them (which I would like to do myself) however when I take a look at them, they are very in depth (to in depth - I just want HTML rendering).
    So my question is: Does anyone know of some simple renderer frameworks which I could take a peek at to get a point in the right direction or some books which would give me idea how to get started writing a renderer?
    Cheers,
    Reacz

    Thanks guys.
    I really want to give it a go on my own, it doesn't neccesarily have to be 100% perfect (in fact it doesn't even have to render them well at all).
    So, any ideas where else I could learn more about Renderers and how they are created for Java apps?
    As I said I have looked at Warrior and a couple of others and they abide by the DOM (Document Object Model) but they are very complicated, I wanted something more simple (if thats possible).
    Any books, or anything else anyone knows which may help me?
    Regards & Thanks,
    Reacz. :)

  • Plzzz write prog to this simple java threads question

    Write a program in C to create four processes. The original processes creates
    two children before it prints out "PARENT". The children processes print
    "CHILD1" and "CHILD2" respectively. The first child process creates a child
    process that prints out "GRANDCHILD".
    Note: The output must be guaranteed to print out in the following order each
    time it is executed:
    GRANDCHILD
    CHILD2
    CHILD1
    PARENT
    a. Write the program using C or C++ and forks to create the children processes.
    b. Write a second program using Java and Threads for the children processes.
    The output statements for CHILD1, CHILD2 and GRANDCHILD must come from print
    statements in the run method of the thread.

    Most people here will not do your homework for you. If you post a reasonable question that shows you've made some effort, and what the results of that effort were, and provides details about what parts you're having trouble with, then somebody will probably provide guidance so that [you can complete the work.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Simple Java Coding Question

    I know this is a simple question, but I can't search for the answer to this because it involves syntax that Google and the like don't seem to search for..
    I am trying to figure out some Java code that I have found. I would like to know what:
    a[--i] and a[++j] mean.
    My first thought was that they meant to look at the position in the array one less (or more) than i (j). But that doesn't seem to be the case. A is an array of Strings, if that matters...
    Thanks for you help.

    muiajc wrote:
    I know this is a simple question, but I can't search for the answer to this because it involves syntax that Google and the like don't seem to search for..
    I am trying to figure out some Java code that I have found. I would like to know what:
    a[--i] and a[++j] mean.
    It mean increase/decrease the int i/j by 1. This is done before it gets you the value of a[]. for example if i=5 and you said a[--i] it is really a[4] and i is now equal to 4;

Maybe you are looking for