Java Servlet/Html link problem

Hi,
I have been using the Java servlet to create the html code itself using the PrintWriter.I would like to know if it possible to input ALL the code into -
PrintWriter out=null;
out.println("<Html><Body>the entrie html code</Body></Html>");
or must I input in this form?-
out.println("<html>");
out.println("<Body>");
out.println("<The entire html code>");
out.println("</Body>");
out.println("</Html>");
Does it really make a difference?
I would also like to know it is possible to retrive data from a database and (via servlet) input the list of data into the combo-box of an html Webpage.
Thank you very much for your assistance.Kindly acknowledge receipt.
Yours sincerely,
Aeshan
PS- I'll send more information soon

Your answers are yes ...and yes.
But don't use:
PrintWriter out=null;
Use:
PrintWriter out = response.getWriter();
Usually the println() method is used to make both the servlet source code ...as well as the html it generates ...a little nicer to read. This may or may not be important to you, but may matter to your employer and those who maintain your code in the future.

Similar Messages

  • Html link problem...

    Hey!
    Just wanned to say to those who answered my post on html link problems, that the problems I had were actualy because of the jdk version! I had jdk1.2 and now I have 1.3 and it works just fine.
    thanx a lot to everyone who tried to help!!!

    hehe i saw the topic "html link problem" posted by amidala and i thought " oh my god is she still struggling!" ;P
    Kewl 'twas not a problem!

  • html:link problem with Mozilla vs. IE

    Hello,
    I am experiencing the following situation.
    In IE the following segment of code works properly:
    <td>
    <table border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
         <html-el:link action="zone3/g036Play">
         <td><html-el:img srcKey="detailsLeft2" bundle="ZONE3_IMAGE_RESOURCE_KEY" border="0" width="17" height="18"/></td>
         <td class="details"><bean-el:message key="couponsHistory.details" bundle="XLTS_MESSAGE_RESOURCE_KEY"/></td>
         <td><html-el:img srcKey="detailsRight2" bundle="ZONE3_IMAGE_RESOURCE_KEY" border="0" width="9" height="18"/></td>
         </html-el:link>
    </tr>
    </table>
    </td>BUT in Mozilla the link doesn't work
    On the other hand, i found out that if i place the <html:link> tag outside of the table, then the link will work properly for mozilla but won't work for IE.
    Is there a way i can work this problem around?
    Thank you very much in advance.
    Frini

    ok, sorry, my mistake, i was looking at the wrong fragment of code.
    It output the HTML code:
       <td><a href="/XltsWeb/zone3/g036Play.web"><img src="images/xlts/details_left_lottery.gif" height="18" width="17" border="0"></td>
       <td class="details">Details</td>
       <td><img src="images/xlts/details_right1_lottery.gif" height="18" width="9" border="0"></a></td>which still doesn't work in Mozilla as a link...
    But if i place <html:link> outside the table and inside TD, i get:
    <td>
      <a href="/XltsWeb/zone3/g036Play.web"><table border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
      <td>
       <td><img src="images/xlts/details_left2_lottery.gif" height="18" width="17" border="0"></td>
       <td class="details">Details</td>
       <td><img src="images/xlts/details_right2_lottery.gif" height="18" width="9" border="0"></td>
       </td>
       </tr>
       </table></a>
    </td>and works in Mozilla, BUT no, none of the above works in IE!!!!!!!!!!!!!!!!!!!!!
    The only code that works in IE, is the first that i posted!!!!

  • html:link problem in struts

    <a href="photo.jsp?cmd=showa&Id=<%=Id)  %> target="thumbs">This is normal coding in jsp. how to use the same coding in struts using <html:link>
    Please Help me.
    Thanks in Advance
    regards
    pooja</a>

    Have a look at this.
    http://struts.apache.org/struts-action/struts-el/tagreference.html#link

  • HTML Link problem (Urgent!)

    I'm writing a prrogram that displays an HTML file. I used a JEditorPane. I tryed using the hyperlinkListener but it doesn't work! here's the class I wrote...
    can anyone help please?
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import browser.*;
    import java.net.*;
    import javax.swing.event.*;
    * Classe :
    * Description :
    * Societe : Medias France
    * @version 1.0
    public class Aide extends JFrame implements HyperlinkListener
         BrowserInterface bI;
         URL url1;
         static Interface parent;
         public Aide(String titre, Interface i)
              super(titre);
              parent = i;
              getContentPane().setLayout(new BorderLayout());
              //bI = new BrowserInterface(jp);
              setBounds(10,10,800,600);
              addWindowListener(new WindowAdapter()
                   public void windowClosing(WindowEvent e)
                   quit(null);
              try
                   url1 = new URL("file:/home/darkazan/java/BDO/tablegen-1.8/help/help.html");
                   //bI.URL_Process(url1);
              catch (MalformedURLException e)
                   System.out.println("probleme " + e.toString());
              JEditorPane editorPane = new JEditorPane();
         editorPane.setEditable(false);
         try
         editorPane.setPage(url1);
         catch (IOException e)
         System.err.println("Attempted to read a bad URL: " + url1);
         JScrollPane editorScrollPane = new JScrollPane(editorPane);
              editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
         editorScrollPane.setPreferredSize(new Dimension(800, 600));
         getContentPane().add(editorScrollPane, "Center");
         pack();
         setVisible(true);
         public void hyperlinkListener(HyperlinkEvent e)
              if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
         // do something on HL click
    System.out.println("ouverture");
              if (e.getEventType() == HyperlinkEvent.EventType.ENTERED)
              // do something on mouse over HL
         // do something on HL click
         System.out.println("bbbbbbbbbbbbbbbbbbbb");
    if (e.getEventType() == HyperlinkEvent.EventType.EXITED)
    // do something on HL click
    System.out.println("ggggggggggggggggggg");
    // do something on mouse moved away from HL
         public void hyperlinkUpdate(HyperlinkEvent e)
         public static void main(String[] args)
              Aide aide1 = new Aide("Help", parent);
         * Quitter l'application
         * @param     e L'evenement recu
         * @return     Sans objet.
         void quit(ActionEvent e)
              parent.bAide.setEnabled(true);
              dispose();
    }

    also check your file protocol it should look like this: file:/// with three slashes(i think?)
    here Mr. Urgent, my html viewer: (and it works) ;P
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import javax.accessibility.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.io.IOException;
    public class iROCHelp extends JPanel implements HyperlinkListener{
    //ATTRIBUTES
    JEditorPane html;
    private static boolean HelpShowing = false;
    private static JFrame selTopic;
    //METHODS
    //Constructor
    public iROCHelp(java.net.URL URLstr){
    //setBorder(new EmptyBorder());
    setLayout(new BorderLayout());
    try{
    URL url = URLstr;
    if(url != null){
    html = new JEditorPane(url);
    html.setEditable(false);
    html.addHyperlinkListener(this);
    JScrollPane scroller = new JScrollPane();
    JViewport vp = scroller.getViewport();
    vp.add(html);
    vp.setBackingStoreEnabled(true);
    add(scroller, BorderLayout.CENTER);
    catch (MalformedURLException e){
    System.out.println("Malformed URL: " + e);
    catch (IOException e){
    System.out.println("IOException: " + e);
    }//HelpTopic CONSTRUCTOR
    public void hyperlinkUpdate(HyperlinkEvent e){
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED){
    linkActivated(e.getURL());
    }//hyperlinkUpdate
    protected void linkActivated(URL u){
    Cursor c = html.getCursor();
    Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
    html.setCursor(waitCursor);
    SwingUtilities.invokeLater(new PageLoader(u, c));
    }//linkActivated
    class PageLoader implements Runnable{
    PageLoader(URL u, Cursor c){
    url = u;
    cursor = c;
    public void run(){
    if (url == null){
    // restore the original cursor
    html.setCursor(cursor);
    Container parent = html.getParent();
    parent.repaint();
    else{
    Document doc = html.getDocument();
    try{
    html.setPage(url);
    catch (IOException ioe){
    html.setDocument(doc);
    finally{
    // schedule the cursor to revert after
    // the paint has happended.
    url = null;
    SwingUtilities.invokeLater(this);
    }//else
    }//run
    URL url;
    Cursor cursor;
    }//PageLoader
    public static void spawnHelp(java.net.URL URLStr){
    if (!HelpShowing){
    selTopic = new JFrame();
    selTopic.getContentPane().setLayout(new BorderLayout());
    selTopic.getContentPane().add(new iROCHelp(URLStr),BorderLayout.CENTER);
    Dimension dim = selTopic.getToolkit().getScreenSize();
    selTopic.setLocation((int)dim.getWidth()/2-selTopic.getWidth()/2,(int)dim.getHeight()/2-selTopic.getHeight()/2);
    selTopic.setSize(500, 400);
    selTopic.setTitle("Remote Operators Console Help");
    selTopic.addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e){
    closeHelp();
    }//windowClosing
    selTopic.show();
    HelpShowing = true;
    }//if help showing
    }//spawnHelp
    public static void closeHelp(){
    if (HelpShowing){
    selTopic.dispose();
    HelpShowing = false;
    }//closeHelp
    }//HelpTopic CLASS

  • HTML link problem in Edge

    I've added a 3 word link to a block of copy in my animation, the problem is the only the first word of the three responds like an link. I have other links in other areas in the animation and they work fine. Here's my code:
    <style>a:link {color:#b8dc70;text-decoration:none;} a:visited {color:#aaaaaa;}a:hover {color:#e69400;}a:active {color:#c97777;}</style><a href = "http://grassrootschange.net/what-is-grassroots-movement/" target=_"self">public health movement</a>
    Only public displays the style attributes and responds like a link. health movement display the style attributes, but not the link.
    Thank you in advance

    Had a look, though a few items:
    - remove all your <style xxxxxxx> xxxxx</style> references that you have within each of your sym.html(" ") string methods; It's not needed. Once you have them removed, move to the next step.
    - Go to the Stage > Compositionready event handler and paste in the following, anywhere
    // start copy here
    $("<style type='text/css'> a:link {color:#b8dc70;text-decoration:none;} a:visited {color:#aaaaaa;}a:hover {color:#e69400;}a:active {color:#c97777;} </style>").appendTo("head");
    // end copy here
    The above will take care of all the style references you were doing in one swoop.
    Optional, but worth doing.
    ---- Back to each of your  smy.html ( "  "); methods
          In most of them there are closing </font> tags but no opening ones; remove them.
          Your target references, they they work, is incorrect.
          You have _"self" for all of them, when the underscore should be inside the quotes, like this: target ="_self"
          Your actual strings within the html () method should start and end with double quotes and any markup tag should be single quoted.
          Example, cleaned up html () method from your file. Note the open/ close double quotes; open/close single quote for markup properties.
    sym.$("TextBuilding").html
    ("A grassroots <a href = 'http://grassrootschange.net/what-is-grassroots-movement/' target='_blank'>public health movement</a> is an organized effort to address threats to the health and safety of a community, led by activated citizens and organizations that devote resources to movement building. The power of a well-run grassroots movement can overcome the dominance of money in politics, making it one of the only ways advocates can achieve lasting change in public health.");
    hth
    Pretty example, btw
    Darrell

  • HTML Link Problem Column Formula

    Hi All,
    I have a hyper link column in the report. I used to make that coumn as a hyperlink using Column Formula. I added the below text in the column formula.
    '<a target="_blank" href="http://gtestenv:9704/analytics/saw.dll?Dashboard&PortalPath=%shared%Sample%testpage&P0=1&P1=eq&*P2=Variance.Level1=100*>' || Test.ShowLevel1 || '</a>'
    when i use this linkformat working fine. If a change in presentation layer table name "Variance" to "Variance Data"
    target="_blank" href="http://gtestenv:9704/analytics/saw.dll?Dashboard&PortalPath=%shared%Sample%testpage&P0=1&P1=eq&*P2="Variance Data".Level1=100*
    this is not working. Filter is not regognized the parameters. In the Address bar the link is shows like
    http://gtestenv:9704/analytics/saw.dll?Dashboard&PortalPath=%shared%Sample%testpage&P0=1&P1=eq&*P2=*
    Please help me how to send that double qutoes in the URL using <a> coumn formula
    Edited by: Guna on Jul 18, 2009 12:22 AM

    And use %22 for the quotes
    %22Variance%20Data%22.Level1which become :
    target="_blank" href="http://gtestenv:9704/analytics/saw.dll?Dashboard&PortalPath=%shared%Sample%testpage&P0=1&P1=eq&P2=%22Variance%20Data%22.Level1=100"The best way to create this Dashboard Url is to create a fake dasbhoard with what you want and to generate the link with the dashboard links :
    http://gerardnico.com/wiki/dat/obiee/presentation_service/obiee_dashboard_url#dashboard_links
    Success
    Nico

  • Problems calling Java Servlets from HTML pages Online

    Hello
    I have created a Web site using Java Servlets, and have acquired some servlet enabled web-space however i am having some difficulty in calling the actual servlets from the HTML pages i was using the line of code as follows
    http://localhost:8080/servlet/....
    followed by the name eg.
    http://localhost:8080/servlet/Login
    however this doesn't seem to be working i have also tried using the exact address of the servlet but this didn't work either
    i.e ..servlet/Login.java
    I was wondering would anyone have any idea as in how the servlets should be called
    Thanks very much

    Once you write the Servlet code, you have to compile and put the classes in the server classpath. To refer these servlets from your pages, you have to configure them in the server configuration(typical a xml file). There you define how you are going to refer to the servlet(/servlet/Logon) and the correponding class.
    -Mak

  • Html link to a servlet

    Hello,
    I am new to Java Servlet programming and I need some help with calling a servlet via a HTML link.
    I have a class which generates a html page:
    package HccMembers;
    public class HccMemberServlet
    public StringBuffer buffer;
    public HccMemberServlet(String sHccId, String sHcId)
    buffer = new StringBuffer(4096);
    this.buffer.append("<HTML>\n ");
    this.buffer.append("<HEAD>\n ");
    this.buffer.append("<TITLE>Members</TITLE>\n");
    this.buffer.append("</HEAD> \n");
    this.buffer.append("<BODY> \n");
    this.buffer.append("<p><ahref='http://localhost:8080/transport/HccMembers/servlet/JCSJobOrderServlet'>New Job Order</a></p>");
    this.buffer.append("</BODY></HTML>");
    Basically, when the user clicks the link a servlet should be invoked. (Below)
    package HccMembers;
    //import java Servlet classes
    import javax.servlet.*;
    import javax.servlet.http.*;
    //import java classes
    import java.io.IOException;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    public class JCSJobOrderServlet extends HttpServlet
    public void init(ServletConfig config) throws ServletException
    System.out.println("hello");
    public void service(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    System.out.println("Hey");           
    The problem is that, when I click the link I get a 404 page not found error. Any ideas?
    I really appreciate any help.

    You need to add couples of lines to the configuration file of your application (web.xml) : first you must say that the class CSJobOrderServlet is a servlet that you want to use, second you must map the servlet to a specific url, then you can use this url whenever you like.
    As an advice, don't use absolute URLs on your application, use only URLs relative to your application root.
    Example for web.xml:
        <servlet>
            <servlet-name> MyFirstServlet</servlet-name>
            <servlet-class>JCSJobOrderServlet</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>MyFirstServlet</servlet-name>
            <url-pattern>/custom_url</url-pattern>
        </servlet-mapping>Now, about the servlet implementation: if you are using System.out.println("Hey") you will see the message on the standard output of the server, and not on the browser as you expected.
    here is a small example:
        public void doGet(HttpServletRequest request,
                          HttpServletResponse response)
          throws IOException, ServletException {
            response.setContentType("text/html");
            PrintWriter writer = response.getWriter();
            writer.println("<html>");
            writer.println("<head><title>Hello response</title></head>");
            writer.println("<body>Hello !</body></html>");
       }For more information see the documentation for servlets and / or a book.
    Iulian

  • Problem in html:link   tag

    i have written one small programme in Struts application please solve this problem
    code is
    ======
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <html:html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title><bean:message key="app.title" /></title>
    </head>
    <body topmargin="0" leftmargin="0" bgcolor="#FFFFFF">
    <h2 align="center"><b><i><font size="6" face="Comic Sans MS" color="#FF0000">Welcome
    page</font></i></b></h2>
    <p> </p>
    <html:errors/>
    <html:form action="login.do" >
    <p align="center"><font face="Arial Black" size="4"><bean:message key="app.username" /> :<html:text property="username" /></font></p>
    <p align="center"><font face="Arial Black" size="4"><bean:message key="app.password" />:<html:password property="password"/></font></p>
    <p align="center"><font face="Arial Black" size="4"><html:submit property="login"/><html:reset property="Clear" /></font></p>
    <p align="center"><font face="Arial Black" size="4"><bean:message key="app.newuser"/>:
    </html:form>
    <html:link href="registration_form.jsp">Register</html:link></font></p>
    </body>
    </html:html>
    In this above programe i have used two ActionForm class one for LoginForm and another is RegisterForm..
    in this welcome page it requires
    username
    password
    if a new user he wants to fill register form
    so the problem in the above code when iam pressing REGISTER link it will shown the follwing errors
    javax.servlet.jsp.JspException: Cannot find bean null in any scope
    at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:938)
    at org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:274)
    at jsp_servlet.__registration_form._jspService(__registration_form.java:164)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:445)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5412)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3086)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2544)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    >
    please solve it
    thanks adavance

    i have writen ACtionForm classes for welcome.jsp and registration_form.jsp..
    can u give good idea how can use to links from page to diffent pages..
    i mean here my aim is if it is new user he wants to enter registration_form.jsp and if it existing user directly he has login and username in welcome.jsp only and he has to enter into Inbox..please give some guidelines on this one
    thanking u

  • Help: No Parameters, HTML Output from Java Servlet

    I have a Java Servlet that reads parameters passed from an HTML form and displays them to another HTML page. I know the servlet is being invoked; however, I am not seeing any HTML output. Sending the output to a file reveals the parameters are coming in as NULL as well.
    I attempted a simple sample app with the same results. Here is what I am running:
    The HTML Form:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Collecting Three Parameters</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FDF5E6">
    <H1 ALIGN="CENTER">Collecting Three Parameters</H1>
    <FORM ACTION="ThreeParams">
    First Parameter: <INPUT TYPE="TEXT" NAME="param1"><BR>
    Second Parameter: <INPUT TYPE="TEXT" NAME="param2"><BR>
    Third Parameter: <INPUT TYPE="TEXT" NAME="param3"><BR>
    <CENTER><INPUT TYPE="SUBMIT"></CENTER>
    </FORM>
    </BODY>
    </HTML>
    The Java Code:
    public class ThreeParams extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Reading Three Request Parameters";
    out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
         "Transitional//EN\">\n" +
    "<BODY BGCOLOR=\"#FDF5E6\">\n" +
    "<H1 ALIGN=\"CENTER\">" + title + "</H1>\n" +
    "<UL>\n" +
    " <LI><B>param1</B>: "
    + request.getParameter("param1") + "\n" +
    " <LI><B>param2</B>: "
    + request.getParameter("param2") + "\n" +
    " <LI><B>param3</B>: "
    + request.getParameter("param3") + "\n" +
    "</UL>\n" +
    "</BODY></HTML>");
    What happens when I "submit" from the form is the same form reloads with the query string in the URL: "http://localhost:8080/ThreeParams/?param1=1&param2=2&param3=3"
    Any assistance with either (or both) would be thoroughly appreciated:
    a) why the parameters are not being passed correctly to the servlet
    b) why the HTML output page is not displayed
    Thanks in advance!
    - Steve

    I have found the answer to my problem listed in another thread.
    Thank you.

  • Separation of Java and HTML in servlets

    I'm starting on my first Java project. It will be a basic table maintenance app using Java Servlets. My question is, what would be a good way to keep my servlet code separated from the HTML code that will be used to generate the pages I'll display to the users. Should I have separate classes that produce each type of HTML? Just looking for a place to start. Thanks.

    Yes it is good idea, essential even. There are three main ways to do this.
    1) Use a third party template system like TEA, FreeMarker or WebMarco.
         http://freemarker.sourceforge.net/
    http://opensource.go.com/Tea/index.html
    http://www.webmacro.org/
    2) Use the Model View Controller Pattern, the Servlet (the controller) processes the requests and dispatches it to a Jsp page (the view) containing beans that reference your data (the model). See this link ( http://java.sun.com/j2ee/blueprints/design_patterns/model_view_controller/index.html )
    3) Produce your own Template system; with page loader/Parser, replacing the relevant 'custom tags' with the correct data.
    My best solution depends on your circumstances,

  • Having problems passing more than one parameter with html:link tag

    Hi guys,
    for my web application I�m using Struts. I�ve got a database with user details. I would like to get users list and link to the details of each user. I wrote the code and everything is working fine only the users list is repeating as many times as users in the list.
    For ex: I have in the database User1, User2 and User3. I would like to have a result like:
    User1
    User2
    User3
    Instead of it I have the result like:
    User1
    User2
    User3
    User1
    User2
    User3
    User1
    User2
    User3
    What I�m doing wrong? Could somebody help me please?
    Thank you in advance
    There is a snippet of the code, which I�m using in jsp:
    <code>
    <logic:iterate id="root" name="user">               
                   <%
                        java.util.HashMap users = new java.util.HashMap();
                        params.put("user",root);
                        pageContext.setAttribute("usersName", users);
                   %>
                   <html:link name=" usersName " scope="page" page="/name.do">
                        <logic:iterate id="folder" name="user">
                             <bean:write name="folder" /><br>
                        </logic:iterate>
                   </html:link><br>
                   </logic:iterate>
    </code>

    Suggestion: next time you post code use the "CODE" button to put code tags around it. It formats much nicer that way :-)
    You have a nested loop structure here.
    <logic:iterate id="root" name="user">
      <%
        java.util.HashMap users = new java.util.HashMap();
        params.put("user",root);
        pageContext.setAttribute("usersName", users);
      %>
      <html:link name=" usersName " scope="page" page="/name.do">
        <logic:iterate id="folder" name="user">
          <bean:write name="folder" /><br>
        </logic:iterate>
      </html:link><br>
    </logic:iterate>Both loops iterate over your "user".
    Your first loop loops over each user.
    Then your second loop also loops over each user - hence you get number of users * number of users = 3 groups of 3.
    If you have 4 users, you would have 4 groups of 4.
    I only see you setting one parameter: "usersName" What other parameters do you need to pass?
    At a guess, the inner loop is unnecessary, and you want to write the users name as the text for the link, and also use it as a link parameter.
    <logic:iterate id="root" name="user">
      <%
        java.util.HashMap users = new java.util.HashMap();
        params.put("user",root);
        pageContext.setAttribute("usersName", users);
      %>
      <html:link name="usersName" scope="page" page="/name.do">
          <bean:write name="user" /><br>
      </html:link><br>
    </logic:iterate>

  • HTML link in a Java?

    Hya,
    How can create a HTML link in Java GUI, for example in a JLabel?
    thanks inadvance

    I'm not quite sure but i think if you add addHyperlinkListener to the jlable it will be seen as a link.
    Have a look at this code example:
    try {
            String url = "http://www.google.com";
            JEditorPane editorPane = new JEditorPane(url);
            editorPane.setEditable(false);
            editorPane.addHyperlinkListener(new MyHyperlinkListener());
        } catch (IOException e) {
        class MyHyperlinkListener implements HyperlinkListener {
            public void hyperlinkUpdate(HyperlinkEvent evt) {
                if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    JEditorPane pane = (JEditorPane)evt.getSource();
                    try {
                        // Show the new page in the editor pane.
                        pane.setPage(evt.getURL());
                    } catch (IOException e) {
        }

  • Problem in html:link tag in struts

    hi every body i have a problem i have to pass two dynamic variable to next page using html:link tag how can i send it
    for example
    <a href = "editEmp.jsp?id=<%= empSno %>&&delete=no"> Edit </a>
    should be coverted into <html:link >and i want to pass 2 parameters to next page how can i do can anybody help

    i have used forward only but how to passs variable dynamically in forward for eaxmpleeee
    i am retreving records from database
    emdID name desig
    1 suresh PM edit
    2 ram PL edit
    when user clecks on link of edit of suresh then i should pass controll to edit page with his empID an parameter............
    i have done this prevoiusly by href tag like
    while (rst.next()) { %>
                        <tr>
                             <% empSno = rst.getInt ("ID");%>
                             <td align = "left"><%= empSno %></td>
                             <td align = "left"><%= rst.getString ("empno") %></td>
                             <td align = "left"><%= rst.getString ("empname") %></td>
                             <td align = "left"><%= rst.getString ("desig") %></td>
                             <td><a href = "strutsEx/ch05/editEmp.jsp?id=<%= empSno %>&&delete=no"> Edit </a>&nbsp&nbsp&nbsp&nbsp<a href = "editEmp.jsp?id=<%= empSno %>&&delete=yes"> Delete </a>
                             </td>
                        </tr>
    now i want to use html:link action in place of HREF can u help me plzzzzzzzzzz

Maybe you are looking for