JEditorPane Html Table Lines

It seems if I load html containing tables into a JEditorPane, the format is less than great. The main problem I have is that none of the table lines show up. I was wondering if there was an option or something I'm overlooking, that would solve this problem. JEditorPane.showTheLinesSeperatingRowsAndColumnsInHtmlTables(true) for instance would be great.
Thanks

if the HTML source produces line, JEditorPane should shouw them as long as HTML 3.2 is used.
Ulrich

Similar Messages

  • HTML Table lines limit

    Hi,
    We are displaying the trip details in a HTML page in ITS server.
    It has been working fine until the upgrade to ECC 6.0.
    Not when the trip has more line items (206 line items) the display gets
    cutoff after 189. This number is not consistent, It varies depending on the
    number of line items. There is no restriction on the number of pages.
    So not sure why this is happening.We tried to increase the number of lines displayed in
    a page , so as to display more line items, But even though those lines were displayed,
    it was blank.
    We tested the function Module that passes the line items in an internal table to the ITS ,
    and that seems to be working fine. Not sure where else to check or how to fix this.
    Any input is appreciated.
    Thank you
    Lalitha

    Hi Lalitha,
    This is due to frame size is the limit. the table is displayed in a frame. and here you are facing the issue.
    Try to increase the frame size in SAP GUI. This problem will get solved.
    Regards
    satya

  • JEditorPane, html, tables and images

    I am trying to use jEditorPane to display an HTML document. If images are included into cells of a table, the width and height of the cells do not adjust to the size of the images (as it happens with common web browsers), no matter what parameters I use for TD and IMG tags.
    Do you experience the same problem? Is there a solution?
    Thanks.
    Ruben Razquin

    Hi Ruben,
    you will have to implement adjustment of table cells yourself to achieve this. With the existing way JEditorPane et. al. render tables table cells always are sized either in default sizes or by attributes explicitly giving the size (such as attribute WIDTH).
    Ulrich

  • JEditorPane: HTML Table: Wrong cells height calculation

    <table>
        <tr>
            �<td width="200" height="5" bgcolor="red"><td>
        </tr>
        <tr>
            <td width="200" height="5" bgcolor="green"><td>
        </tr>
        <tr>
            <td width="200" height="5" bgcolor="blue"><td>
        </tr>
    </table>
    Just for last row I get the specified height "5", and two first ones have height "19". It is true for any height that less than 19. Is it a bug? How I can handle this and get the right behavior?

    Hi Ruben,
    you will have to implement adjustment of table cells yourself to achieve this. With the existing way JEditorPane et. al. render tables table cells always are sized either in default sizes or by attributes explicitly giving the size (such as attribute WIDTH).
    Ulrich

  • Display HTML Tables In JEditorPane

    Hi all,
    I am Editing an HTML Document in a JEditorPane.I've Noticed that The HTMLEditorKit has many flaws.
    I tried to fill them by registering my own tag actions for some tags. Now the new problem that I am facing is how an html table is displayed : The cellborders ares not visible. So i can see the content of the table, but not its borders. What should I do to make them show out ?
    thanx

    I had some problems with using HTML Tables with JEditorPane (it's really flaky). What I found was you have to be very specific when you create the table. Meaning, the cells have to be set using exact pixel sizes, not relative sizes or percentages. This is a pain, but if you do that then it should work.
    <table width=400 border=1 cellspacing=0 cellpadding=1> etc.......m

  • How to change attributes of HTML table in HTMLDocument

    Hi
    I am trying to change background of table cell but unsuccessfully. First of all I did not found any suitable method in API so I have to inherit HTMLDocument and make my own
    public static class ExtendedHtmlDocument extends HTMLDocument {
    public void replaceAttributes(Element element, AttributeSet attributes, HTML.Tag tag) {
    try {
      writeLock();
      int offset = element.getStartOffset();
      int length = element.getEndOffset() - offset;
      MutableAttributeSet mutableAttributes = (MutableAttributeSet) element.getAttributes();
      mutableAttributes.removeAttributes(attributes.getAttributeNames());
      mutableAttributes.addAttributes(attributes);
      DefaultDocumentEvent changes = new DefaultDocumentEvent(offset, length, DocumentEvent.EventType.CHANGE);
      changes.addEdit(new AttributeUndoableEdit(element, attributes.copyAttributes(), true));
      changes.end();
      fireChangedUpdate(changes);
      fireUndoableEditUpdate(new UndoableEditEvent(this, changes));
    finally {
      writeUnlock();
    }When I usethis code and dump exisiting document I see changes, e.g. I changed background in cell:
    private void setCellBackground(Element element) {
      SimpleAttributeSet set = new SimpleAttributeSet();
      set.addAttribute("bgcolor", "black");
      doc.replaceAttributes(element, set, HTML.Tag.TD);
      doc.dump(System.out);
      //editor.setText(editor.getText());
    } and extract from dump
    <html
      name=html
    >
        <table
          width=100%
            <td
              bgcolor=black
              name=td
            >But I do not see changes in the view, cell has the same background. The view is updated only if I uncomment last line "editor.setText(editor.getText())", but I think it is not good to update this way.
    Thanks.

    Here I put an example and you can play with different strange aspects of HTMLDocument implementation
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class TableEditor implements ActionListener {
        private JEditorPane editor;
        private ExtendedHtmlDocument doc;
        public TableEditor(JEditorPane editor, ExtendedHtmlDocument doc) {
            this.editor = editor;
            this.doc = doc;
        public void actionPerformed(ActionEvent e) {
            Element element = doc.getCharacterElement(editor.getCaretPosition());
            Element parent = element.getParentElement();
            while (parent != null && !parent.getName().equals("td")) {
                parent = parent.getParentElement();
            if (parent == null) {
                JOptionPane.showMessageDialog(null, "Select cell to edit properties");
            } else {
                SimpleAttributeSet attributes = new SimpleAttributeSet();
                attributes.addAttribute(HTML.Attribute.BGCOLOR, "gray");
                attributes.addAttribute(HTML.Attribute.ALIGN, "right");
                doc.replaceAttributes(parent, attributes);
    //            doc.replaceAttributes(parent, attributes);
    //            editor.setText(editor.getText());
                doc.dump(System.out);
        private static class ExtendedHtmlEditorKit extends HTMLEditorKit {
            public Document createDefaultDocument() {
                StyleSheet styles = getStyleSheet();
                StyleSheet styleSheet = new StyleSheet();
                styleSheet.addStyleSheet(styles);
                ExtendedHtmlDocument doc = new ExtendedHtmlDocument(styleSheet);
                doc.setParser(getParser());
                return doc;
        public static class ExtendedHtmlDocument extends HTMLDocument {
            public ExtendedHtmlDocument(StyleSheet styles) {
                super(styles);
            public void replaceAttributes(Element element, AttributeSet attributes) {
                try {
                    writeLock();
                    MutableAttributeSet mutableAttributes = (MutableAttributeSet) element.getAttributes();
                    mutableAttributes.removeAttributes(attributes.getAttributeNames());
                    mutableAttributes.addAttributes(attributes);
                    int offset = element.getStartOffset();
                    int length = element.getEndOffset() - offset;
                    DefaultDocumentEvent changes = new DefaultDocumentEvent(offset, length, DocumentEvent.EventType.CHANGE);
                    changes.addEdit(new AttributeUndoableEdit(element, attributes.copyAttributes(), true));
                    changes.end();
                    fireChangedUpdate(changes);
                    fireUndoableEditUpdate(new UndoableEditEvent(this, changes));
                finally {
                    writeUnlock();
        public static void main(String args[]) throws Exception {
            HTMLEditorKit kit = new ExtendedHtmlEditorKit();
            final ExtendedHtmlDocument doc = (ExtendedHtmlDocument) kit.createDefaultDocument();
            StringReader reader = new StringReader("<table border='1' width='100%'>\n" +
                    "    <tr>\n" +
                    "        <td>Cell1-1</td>\n" +
                    "        <td>Cell1-2</td>\n" +
                    "    </tr>\n" +
                    "    <tr>\n" +
                    "        <td>Cell2-1</td>\n" +
                    "        <td>Cell2-2</td>\n" +
                    "    </tr>\n" +
                    "    <tr>\n" +
                    "        <td>Cell3-1</td>\n" +
                    "        <td>Cell3-2</td>\n" +
                    "    </tr>\n" +
                    "</table><p>paragraph</p>");
            kit.read(reader, doc, 0);
            final JEditorPane editorPane = new JEditorPane();
            editorPane.setIgnoreRepaint(false);
            editorPane.setEditable(true);
            editorPane.setEditorKit(kit);
            editorPane.setDocument(doc);
            JScrollPane scrollPane = new JScrollPane(editorPane);
            JPanel menu = new JPanel(new FlowLayout(FlowLayout.LEFT));
            menu.add(new JButton(new AbstractAction("Cell properties") {
                public void actionPerformed(ActionEvent e) {
                    new TableEditor(editorPane, doc).actionPerformed(e);
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().setLayout(new BorderLayout());
            frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
            frame.getContentPane().add(menu, BorderLayout.NORTH);
            frame.setSize(800, 500);
            frame.setVisible(true);
    }Look at actionPerformed implemetation I am going to change cell background and alignment - background is changed but alignment is not, when you uncomment second doc.replaceAttributes(parent, attributes) - it will work. In both cases align attribute exists in cell (look at the dump in system.out)

  • Fix for PENDING in javax.swing.text.html.ParagraphView line #131

    Investigating source of HTMLEditorKit I found many PENDING things. That's fix for one of them - proper minimal necessary span detecting in table cells.
    Hope it will help to somebody else.
    import javax.swing.*;
    import javax.swing.text.html.*;
    import javax.swing.text.html.ParagraphView;
    import javax.swing.text.*;
    import java.awt.*;
    import java.text.*;
    import java.util.ArrayList;
    public class App extends JFrame {
        public static String htmlString="<html>\n" +
                "<body>\n" +
                "<p>The following table is used to illustrate the PENDING in javax.swing.text.html.ParagraphView line #131 fix.</p>\n" +
                "<table cellspacing=\"0\" border=\"1\" width=\"50%\" cellpadding=\"3\">\n" +
                "<tr>\n" +
                "<td>\n" +
                "<p>111111111111111111111111111111111<b>bold</b>22222222222222222222222222222</p>\n" +
                "</td>\n" +
                "<td>\n" +
                "<p>-</p>\n" +
                "</td>\n" +
                "</tr>\n" +
                "</table>\n" +
                "<p></p>\n" +
                "</body>\n" +
                "</html>";
        JEditorPane editor=new JEditorPane();
        JEditorPane editor2=new JEditorPane();
        public static void main(String[] args) {
            App app = new App();
            app.setVisible(true);
        public App() {
            super("HTML span fix example");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JSplitPane split=new JSplitPane(JSplitPane.VERTICAL_SPLIT, createFixedPanel(), createOriginalPanel());
            getContentPane().add(split);
            setSize(700, 500);
            split.setDividerLocation(240);
            setLocationRelativeTo(null);
        JComponent createOriginalPanel() {
            JPanel p=new JPanel(new BorderLayout());
            p.add(new JLabel("Original HTMLEditorKit"), BorderLayout.NORTH);
            HTMLEditorKit kit=new HTMLEditorKit();
            editor2.setEditorKit(kit);
            editor2.setContentType("text/html");
            editor2.setText(htmlString);
            p.add(new JScrollPane(editor2), BorderLayout.CENTER);
            return p;
        JComponent createFixedPanel() {
            JPanel p=new JPanel(new BorderLayout());
            p.add(new JLabel("Fixed HTMLEditorKit"), BorderLayout.NORTH);
            HTMLEditorKit kit=new MyHTMLEditorKit();
            editor.setEditorKit(kit);
            editor.setContentType("text/html");
            editor.setText(htmlString);
            p.add(new JScrollPane(editor), BorderLayout.CENTER);
            return p;
    class MyHTMLEditorKit extends HTMLEditorKit {
        ViewFactory defaultFactory=new MyHTMLFactory();
        public ViewFactory getViewFactory() {
            return defaultFactory;
    class MyHTMLFactory extends HTMLEditorKit.HTMLFactory {
        public View create(Element elem) {
            View v=super.create(elem);
            if (v instanceof ParagraphView) {
                v=new MyParagraphView(elem);
            return v;
    class MyParagraphView extends ParagraphView {
        public MyParagraphView(Element elem) {
            super(elem);
        protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r) {
            r = super.calculateMinorAxisRequirements(axis, r);
            float min=getLongestWordSpan();
            r.minimum = Math.max(r.minimum, (int) min);
            return r;
        public float getLongestWordSpan() {
            if (getContainer()!=null && getContainer() instanceof JTextComponent) {
                try {
                    int offs=0;
                    JTextComponent c=(JTextComponent)getContainer();
                    Document doc=getDocument();
                    int start=getStartOffset();
                    int end=getEndOffset()-1; //don't need the last \n
                    String text=doc.getText(start, end - start);
                    if(text.length() > 1) {
                        BreakIterator words = BreakIterator.getWordInstance(c.getLocale());
                        words.setText(text);
                        ArrayList<Integer> wordBounds=new ArrayList<Integer>();
                        wordBounds.add(offs);
                        int count=1;
                        while (offs<text.length() && words.isBoundary(offs)) {
                            offs=words.next(count);
                            wordBounds.add(offs);
                        float max=0;
                        for (int i=1; i<wordBounds.size(); i++) {
                            int wStart=wordBounds.get(i-1)+start;
                            int wEnd=wordBounds.get(i)+start;
                            float span=getLayoutSpan(wStart,wEnd);
                            if (span>max) {
                                max=span;
                        return max;
                } catch (BadLocationException e) {
                    e.printStackTrace();
            return 0;
        public float getLayoutSpan(int startOffset, int endOffset) {
            float res=0;
            try {
                Rectangle r=new Rectangle(Short.MAX_VALUE, Short.MAX_VALUE);
                int startIndex= layoutPool.getViewIndex(startOffset,Position.Bias.Forward);
                int endIndex= layoutPool.getViewIndex(endOffset,Position.Bias.Forward);
                View startView=layoutPool.getView(startIndex);
                View endView=layoutPool.getView(endIndex);
                int x1=startView.modelToView(startOffset,r,Position.Bias.Forward).getBounds().x;
                int x2=endView.modelToView(endOffset,r,Position.Bias.Forward).getBounds().x;
                res=startView.getPreferredSpan(View.X_AXIS)-x1;
                for (int i=startIndex+1; i<endIndex; i++) {
                    res+=layoutPool.getView(i).getPreferredSpan(View.X_AXIS);
                res+=x2;
            } catch (BadLocationException e) {
                e.printStackTrace();
            return res;
    }Regards,
    Stas

    I'm changing the foreground color with
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setForeground(attr, newColor);
    int start=MyJTextPane..getSelectionStart();
    int end=MyJTextPane.getSelectionEnd();
    if (start != end) {
    htmlDoc.setCharacterAttributes(start, end, attr, false);
    else {
    MutableAttributeSet inputAttributes =htmlEditorKit.getInputAttributes();
    inputAttributes.addAttributes(attr);   

  • Transfer of a HTML table value to corr. R/3 table

    I have a custom ESS service on which almost all Input fields are displayed using SAPgui for HTML, but one -- table control is done manually -- using pure HTML code;
       `SAP_DynproLayerBegin(024,017,014,001)`
       `SAP_InputField("WA32-ZZ_LICENSE2")`
       `SAP_DynproLayerEnd()`
    CUSTOM TABLE CONTROL ****    
      `SAP_DynproLayerBegin(004,019,083,006)`
     `#ZESS_WHO`
                   <!content table>
                   `if  ( TAB_PHONES-PTYPE.dim > 0 )`
    `repeat with j from 1 to TAB_PHONES-PTYPE.dim`
    `if ( CCODE.dim > 1 )`
    `elseif ( CCODE.dim == 1 )`
    `end`
    `if ( OKCODE == 'CHAN' )`
    `else`
    `end`
    `end`
    Phone type 
    Country Code 
    Area Code 
    Local Phone no. 
    Extension 
    `TAB_PHONES-PTYPE[j]` 
    `if ( OKCODE == 'CHAN' )`
    `CCODE` `CCODE_TXT` `else`
    `CCODE` `CCODE_TXT` `end`  `end`
    `CCODE_TXT[1]`
    `TAB_PHONES-ACODE[j]` 
    `TAB_PHONES-PHONE[j]` 
    `TAB_PHONES-EXT[j]` 
    `end`
          `SAP_DynproLayerEnd()`
    How do I get the value back from these HTML table control back to my actual R/3 table control -- like moving the new area code -- the user has entered to table control area code? And where do I write the code --ITS service side or corresponding R/3 tcode side? Please advise.

    Hi Kshitij,
    Not 100% sure if I understand this correctly, but do you have to use a table control on the R/3 side for it? You might also want to consider a Step-Loop instead. I used them a lot in cases when I had an undefinded number of lines with input fields and wanted to allow paging forwards backwards - like displaying 15 on each page.
    But I also can't see why this shouldn't work with a table control. What's the exact problem?
    Regards,
    Michael

  • I want to create an HTML table of img maps dynamically from DB retrieves...

    Hi,
    How do I build dynamic HTML code in a function and then populate a HTML region to render it.. (did I say that right?)
    I want to create an HTML table of img maps dynamically from DB retrieves...
    Thank you, Bill

    Vikas and Andy,
    Using Andy's code I'll go further...
    I want to create a function that returns HTML code that has been built dynamically.
    create or replace function "GET_CH_TABLE"
    return VARCHAR2
    is
    HTML_STRING VARCHAR2(2000); -- Create a string variable
    BEGIN
    HTML_STRING:= '<table align="center">' ||chr(10)||
    ' <tr>' ||chr(10)||
    ' <td> TEST ' ||chr(10)||
    ' /td>' ||chr(10)||
    ' /tr>' ||chr(10)||
    ' tr>' ||chr(10)||
    ' td>' ||chr(10)||
    ' a href=https:// ............etc. etc.. building the <TABLE> and <TD> cells having whatever I want... example.. changing the name of an image dependant on something else..
    return HTML_STRING; -- output the string to the region
    --also tried htp.p(HTML_STRING);
    END;
    =====================================
    Building the dynamic HTML is not my problem. It is how to get it into a region and to be read as HTML from a function call...
    I'd like the source of the region to be the returned HTML from a function call to GET_CH_TABLE();
    but it gives error:
    ORA-06550: line 1, column 7: PLS-00221: 'GET_CH_TABLE' is not a procedure or is undefined
    ORA-06550: line 1, column 7: PL/SQL: Statement ignored
    Debug:
    1: begin
    2: GET_CH_TABLE();
    3: end;
    I

  • Html document ... button in am html table

    Hi,
    I have been exploring the dd classes for some days now. I have a persistent problem which I can not find a way of resolving. I create an html table into which I want to put text and buttons. If for every column I only put in text, then the alignement is quite acceptable. That is the height of the cells are commensurate with the height of the text, or there does not appear to be any padding in the cells above or elow the texts.
    Now to add a button I first add a form area in the column which will contain the button. This works fine but then the height of the cell is no longer just the height of the button. I have tried the methods NO_LINEBREAK( start = 'X' ) and NO_LINEBREAK( end = 'X' ) at the begining and end of the column, that is before going to the next column.
    This has the effect of removing the first break only, so the top of the button is just below the cell top but the bottom of the button is one line break away from the bottom of the cell. So it would appear that a for area always ends with a line break.
    The only way I found to almost do this is to assign 'X' to the attribute line_with_layout. Which should not be done and adds a column to the table anyway.
    So how do I make a cell with the same height as the button taht is inside it.
    Many thanks,
    PD
    Surely there is some simple method.

    Hi,
    Let me send the code snippets. I have tried all that is available. Either there is something missing or I am doing this wrong :
    This first snippets works the best but adds two extra columns after each button. with lv_button = 2 this produces four columns even though I only created for 2.
    create the table
      CALL METHOD gobj_html_doc->add_table
        EXPORTING
          no_of_columns               = lv_columns
          width                       = '100%'
          cell_background_transparent = 'X'
          border                      = '0'
        IMPORTING
          table                       = lv_table_element
          tablearea                   = lv_table_area.
    add columns
      DO lv_columns TIMES.
        lv_width = lv_i MOD 2.
        IF lv_mod EQ 0.
          lv_str = '30%'.
        ELSE.
          lv_str = '70%'.
        ENDIF.
        ADD 1 TO lv_i.
        CALL METHOD lv_table_element->add_column
          EXPORTING
            width  = lv_width
          IMPORTING
            column = lv_column.
        APPEND lv_column TO lt_column.
      ENDDO.
    add buttons
      LOOP AT lt_column INTO lv_column.
        CALL METHOD lv_column->add_form
          IMPORTING
            formarea = lv_form_area.
        lv_form_area->is_line_with_layout = 'X'.
        CALL METHOD lv_form_area->add_button
          EXPORTING
            sap_icon = 'ICON_CHANGE'
          IMPORTING
            button   = lobj_button.
         CALL METHOD lv_table_element->new_row.
      ENDLOOP.
    the following does not work either but no extrra columns are added.
    add buttons
      LOOP AT lt_column INTO lv_column.
        CALL METHOD lv_column->add_form
          IMPORTING
            formarea = lv_form_area.
        lv_form_area->line_with_layout( start = 'X' ).
        CALL METHOD lv_form_area->add_button
          EXPORTING
            sap_icon = 'ICON_CHANGE'
          IMPORTING
            button   = lobj_button.
         CALL METHOD lv_table_element->new_row.
         lv_form_area->line_with_layout( end = 'X' ).
      ENDLOOP.
    and the folling does not help much either.
    add buttons
      LOOP AT lt_column INTO lv_column.
        CALL METHOD lv_column->add_form
          IMPORTING
            formarea = lv_form_area.
        lv_form_area->no_line_break( start = 'X' ).
        CALL METHOD lv_form_area->add_button
          EXPORTING
            sap_icon = 'ICON_CHANGE'
          IMPORTING
            button   = lobj_button.
         CALL METHOD lv_table_element->new_row.
         lv_form_area->no_line_with_layout( end = 'X' ).
      ENDLOOP.
    all I can tell is that there is always a <br> token at the end of the form area. Perhaps the answer is to redefine the method in a derived class?
    If you have more ideas I am certainly opened to them ...
    thanks,
    PD.

  • Save as HTML - tables?

    Hello,
    we are trying to save the FM document as HTML using the built in save as functionality. The tables are exported, but no ruling/borders and straddling information is reflected in the output HTML.
    Does anybody know if there is a way to make FM to export tables with formatting information or any tool that is able to do that?
    Thanks in advance.
    Best regards,
    Viktor

    FM10.
    I don't have FM10, and haven't tried HTML generation since FM6 or so, but anyone who can help needs to know the version.
    but no ruling/borders and straddling information is reflected in the output HTML.
    The FM10 on-line help says, in the Troubleshooting and tips on HTML conversion
    Make sure the table formats you use have regular ruling lines defined for at least one body row. Otherwise, the HTML tables will have no lines around table cells.
    I would expect straddles to be converted to spans, since HTML has attributes for that.
    can you suggest some 3rd party sw?
    I'm not sure that's necessary or desired. Earlier versions of Frame used WebWorks Publisher. HTML generation is now built in. I don't know if you can even get WWP for FM10, or if it would provide any features not standard in FM10.

  • HTML table display issues in Safari and Firefox

    Hey,
    A few days ago, in both firefox and safari, i noticed that whenever i go to certain sites with (i'm assuming) what are HTML tables, they aren't displaying properly. The tables are going way bigger than they should.
    ex. When i go to craigslist.org and click on any link, each item on the page has way more space between lines than it should. To see what i mean check out these screen capture.
    http://www.killtheteleprompter.com/picture1.png
    http://www.killtheteleprompter.com/picture2.png
    Also, perhaps a related issue, in Firefox, the page scrolling isn't smooth anymore when i use my trackpad.
    I tried trashing the preferences for each browser in my library, to no avail. Any help would be awesome. thanks

    hey thanks. The links in the orgininal post are fixed. To view the difference, look at the captures, then type in the url that appears in the captures to see what it should look like.
    http://www.killtheteleprompter.com/picture1.png
    http://www.killtheteleprompter.com/picture2.png

  • Show results from the database to html tables?

    Hi,
    I am a PHP programmer and did a successful CMS program for a company. Now I have another project which is a web based system.
    I basically know how to do it and finish it in PHP.. but I am trying to do it using J2EE.. I am trying to learn J2EE now since I have been programming
    on J2SE for quite sometime..
    I am trying to show the results from a MySQL database on a table on J2EE but I am having hard time doing that. I am trying to research online and reading books but with no luck I can't find any resources on how to do that..If you guys can lead me into a resource where I can read how to do it? or just give any ideas on how to do it correctly I'll try to read and learn I will very much appreciate it.. here's my coding please look at it. Thank you very much
    I want to make it like this in a html table:
    userid username activated task
    1 alvin y delete(this will be a link to delete the user)
    Right now this is what I was able to do so far:
    Userid username activated task
    1
    alvin
    y
    Here are my codes... I am not even sure if I am doing it in the correct way...
    User.java
    mport java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.List;
    public class Users {
    public List getUsers(){
    List names = new ArrayList();
    try{
    Connection con = DBConnect.getConnection();
    Statement stmt = con.createStatement();
    String sql = "select * from users";
    ResultSet rs = stmt.executeQuery(sql);
    while(rs.next())
    String userid = rs.getString("user_id");
    String usernames = rs.getString("user_name");
    String password= rs.getString("password");
    String activated= rs.getString("activated");
    names.add(userid);
    names.add(usernames);
    names.add(password);
    names.add(activated);
    catch(SQLException e)
    System.out.print(e);
    catch(Exception e)
    System.out.print(e);
    return names;
    UserServlet.java
    import java.io.IOException;
    import java.util.List;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class UsersServ extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Users be =new Users();
    List result = be.getUsers();
    request.setAttribute("user_results", result);
    RequestDispatcher view = request.getRequestDispatcher("manage_users1.jsp");
    view.forward(request, response);
    manage_users1.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@page import = "java.util.*" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <%
    List results = (List)request.getAttribute("user_results");
    Iterator it = results.iterator();
    out.print("<table border = 1>");
    out.print("<th>");
    out.print("userid");
    out.print("</th>");
    out.print("<th>");
    out.print("username");;
    out.print("</th>");
    while(it.hasNext()){
    out.print("<tr><td> " + it.next()+"</td></tr>");
    out.print("</table>");
    %>
    </body>
    </html>

    I suggest:
    1: you use this:
    e.printStackTrace()
    instead of this:
    System.out.print(e);
    so it will tell you what line it crashed on.
    2: In the code below,here is how you mix coding html tags and java scriptlets
    (you should never have to use out.print()):. In a later project, you can learn how to use JSTL
    instead of java scriplets (I suggest using java scriptlets for now until you have more JSP experience).
    FROM:
    <html>
    <%
    //some java code goes here
    out.print("<th>");
    //some more java code goes here
    out.print("<tr>");
    %>
    TO:
    <html>
    <% //some java code goes here%>
    <th>
    <%//some more java code goes here%>
    <tr>
    3: Put a lot of System.println() statements in your *.java classes to verify what its doing (you can learn how to use a debugger later).
    4: I highly recommend reading a book on JSP/servlets cover to cover.
    Here's a simple MVC design approach I previously posted:
    http://forums.sun.com/thread.jspa?messageID=10786901

  • Please help me capturing data from HTML table

    Hello Everyone,
    Our Storage subsystem generates a html table containing all LUN allocation for printing. I am saving this html file on disk to collect all table infomation and to put it into a database.
    I am having problems extracting table information from the html file. I tried using regular expressions but still not going anywhere. Below is a sample few lines from the html file.
    Please your help is appreciated solving this problem how to collect this information from a HTML file or if Java has any class for this type of purpose.
    Please advice
    arsi
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <!-- saved from url=(0068)https://10.210.44.14/cgi/rsConfigPrintDisplay?200702121685061633,FS,2 -->
    <HTML><HEAD><TITLE>Volume Assignments</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <META content="MSHTML 6.00.2900.3020" name=GENERATOR></HEAD>
    <BODY><FONT face="Times New Roman,Times" size=2>
    <TABLE cellSpacing=1 cellPadding=3 border=2>
    <CAPTION>
    <H2>Volume Assignments</H2></CAPTION>
    <TBODY>
    <TR vAlign=top>
    <TH><FONT face="Times New Roman,Times" size=2>Volume</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>Location</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>LSS</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>Volume Type</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>Size</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>Storage Type</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>Host Port</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>Host Nicknames</FONT></TH></TR>
    <TR vAlign=top>
    <TD><FONT face="Times New Roman,Times" size=2>02A-25015</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>Device Adapter Pair 1</FONT>
    <BR><FONT face="Times New Roman,Times" size=2>Cluster 1, Loop A</FONT>
    <BR><FONT face="Times New Roman,Times" size=2>Array 2, Vol 042</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>0x10</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>Open System</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>000.9 GB</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>RAID-5 Array</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>Fibre Channel</FONT>
    <BR><FONT face="Times New Roman,Times" size=2>ID 00, LUN 502A</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>R1L01_0,</FONT> <BR><FONT
    face="Times New Roman,Times" size=2>R1L01_1,</FONT> <BR><FONT
    face="Times New Roman,Times" size=2>R2L08_1,</FONT> <BR><FONT
    face="Times New Roman,Times" size=2>R2L08_0,</FONT> <BR><FONT
    face="Times New Roman,Times" size=2>S3L06_0, S3L06_</FONT> <BR><FONT
    face="Times New Roman,Times" size=2>1, S4L06_0,</FONT> <BR><FONT
    face="Times New Roman,Times" size=2>S4L06_1</FONT></TD></TR>
    <TR vAlign=top>

    i wrote the programme for 2 stepper motor as attachment file below. they are run. but when the "start" button is ON then the "emergency stop" is not effects.
    for "emergency stop" functions, i used 4 limit contactors. if one of them is "on" then the programme will be stop.
    but in fact, when the system is running, i can not stop if one of the limit contacor is on.
    cuold you please help me to do with this problem.
    thanks
    Attachments:
    EMERGENCY STOP.vi ‏435 KB
    toolpaths-ut.vi ‏64 KB
    parallel program motor 1,2.vi ‏96 KB

  • Another JEditorPane HTML performance thread

    I've seen quite a few posts on the forums about people having serious performance issues using JEditorPane or JTextPane with large text. I haven't seen any solutions or work-arounds mentioned though, so I'm just going to throw this one out there again...
    To sum up the issue, it appears that calling setText() on a JEditorPane or JTextPane is terribly inefficient. At the very least when trying to display HTML content. I have an HTML table that I would like to display in my app. It's not unreasonably large (perhaps 1000 small rows), but the setText() method takes anywhere between 30seconds and 1 minute to execute. During this time, the memory footprint of my skyrockets and the second attempt to call setText() will result in a OutOfMemoryException.
    The issue seems to be captured in the following bug:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4203912
    However, this bug was closed for 1.5 release of Java, and I'm still experiencing the issue on the latest JRE currently available (1.5.0_05).
    The performance as it is now is pretty unreasonable. Does anyone have any sort of work-around? I've heard a custom implementation of the Document mentioned in one of the posts, but no code examples were given.
    Does anyone have any further input / help on this issue?
    Thank you.

    JEditorPane and JTextPane can't handle plain String text directly.
    Their M of MVC is Document.
    Try preparing a full fledged Document object and set it to them panes.

Maybe you are looking for

  • How to join two lists and display the results in datasheet view.?

    hello, i have two lists that i would like to join, i know a method that has been described  in the link below http://www.codeproject.com/Articles/194252/How-to-Link-Two-Lists-and-Create-a-Combined-Ciew-i however, here the data view is only limited to

  • Mouse Pointer Disappearing and reappearing

    For the past few days my Mouse Pointer will randomly disappear for unspecified lengths and then reappear. I am using the new Blue Tooth Magic Mouse. It also happens with a wired mouse. I have searched high and low for an answer. I however fall to any

  • Animating a dvd menu

    hello everyone, Im currently working on a dvd project and i was wondering...i need to do a layout for the main menu where Planets are the buttons to different menus. but instead of havin the menu static..when u switch buttons the planets rotate to th

  • Stop Re-triggering of PR release strategies for closed PR's.

    Hi, Scenario is like, PR raised and converted it into PO and material has been received. After Receipt of material, system is allowing to change the quantities by un-releasing the release strategies. Once material receipt is completed, system should

  • APEX... query run time

    Hi, My report is based on a view which holds apprx 15 million rows and 15- 20 columns... it is currently taking almost a mint to two to pull the data... May I know if there is a faster way to pull this info...? Thanks again in advance