Html link in java

I'm looking for a way to have a JButton in my java applet that will load up a new page from the applet page when it is clicked. Basically I'm making a game, and the registration system will be done in php, so I don't want to create the same registration system in my java application, so I need a way to link to the webpage.

Look at the AppletContext class for methods to interact with the browser, such as showDocument(URL)
Pete

Similar Messages

  • 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) {
        }

  • html:link .... Struts

    I want a Link as action
    MyJsp.jsp
    <html:link action="/MyAction?myParam=true">MyText</html:link>
    MyAction.java
    in der Methode execute (...........)
    String Str = request.getParameter("MyParam");
    the pProblem I becom the Str null whay ????
    thanks

    You can't map the action directly to an Action class.
    You have to map it via the struts-config.xml with an action like:
    <action path="/myAction" type="MyAction"/>
    And call this action from the jsp by f.ex.
    <% pageContext.setAttribute("MyParam", "Hello"); %>  <!--just adding a parameter -->
    <html:link action="/myAction" name="MyParam"/>The name attribute specifies the query string parameter(s).
    You should be able to access the parameter now in MyAction with your original execute method.

  • How to create hyperlink in Html page using Java

    Hello every one
    I want to know that how can I create a hyperlink in Html page using java ?
    Let for example
    I have code like this and i want to give hyperlink to it using java.
    rember that i am creating node using this id="name" which give me multiple value. and i want to assign diff link to each name..?
    <tr>
    <td ><span id="name"></span>
    </tr>

    but i m using this code to create node in html file
    HTMLLIElement li = (HTMLLIElement)appHTML.createElement("LI");
    Text txt = appHTML.createTextNode(name);
    li.appendChild(txt);
    appHTML.getElementById("name").appendChild(li);
    this will display all name value which is coming from database,
    and i want to assign a hyperlink to it,
    I have id with name also so I thought that using id i will
    create javascript like
    function popup(id)
         if(id==1)
              var n1 = window.open("../list/name1.html");
         if(id==2)
              var n1 = window.open("../list/name2.html");
    this way i want to popup particular file if i can pass id value in this function
    so want hyperlink like
    name

  • How to use the html:link with a arraylist

    Hi everyone:
    I want to display the data using struts html:link.
    I query the database and place all the data to javabean,later place all the javabean to ArrayList.In Action,I use the "request.setAttribute("lovetable",articlelist) to set request to jsp page.
    I want to pass a parameter "id" use the hyperlink so I can get the parameter when I click the hyperlink.
    But how to use html:link to display it?
    I use <html:link action="viewtopic.do" paramId="id" paramName="lovetable" paramProperty="id"/>,it can't work and Tomcat report error :
    org.apache.jasper.JasperException: No getter method for property id of bean lovetable
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    The lovetable is a ArrayList and it don't have a getter or setter method.
    How to use it pass parameter? :( Thks

    Thank you.
    I use the bean:define successful.And display all the data to jsp.My jsp code is:
    <logic:iterate id="love" name="lovetable">
    <bean:define id="idbean" name="love"/>
    <tr bgcolor="<%=color%>">
    <td><bean:write name="love" property="id"/></td>
    <td><html:link forward="viewtopic" paramId="id" paramName="idbean" paramProperty="id"><bean:write name="love" property="title"/></html:link></td>
    <td><bean:write name="love" property="name"/></td>
    <td><bean:write name="love" property="time"/></td>
    </tr>
    </logic:iterate>
    In Action : request.setAttribute("lovetable",articlelist)
    ResutlSet rs=.............
    List articlelist=new ArrayList();
    while(rs.next()){
    articlebean bean=new articlebean();
    bean.setName(rs.getString("name"));
    bean.setTitle(rs.getString("title"));
    articlelist.add(bean);
    The above code will work property.
    The Tag "html:link" need bean to work other than arraylist so I iterate all the bean out.
    The Tag "logic:iterate" need collection to work so I make Action return a List.
    right?
    Any idea? :)

  • 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>

  • How to render HTML files in Java?

    I've read a bit about rendering HTML files using JEditorPane, but been told it's quite limited, and doesn't handle many events other than Hyperlinks stuff...
    I heard that Java bean has a slight more advanced HTML renderer, is that right?
    The thing is that I'm hoping to create a simple (static) HTML editor using Java, but need something to render the HTML file...and I need more event handleling, e.g. mouse click on what element (text, image or table) of the rendered HTML file.
    Can someone please give me some ideas?

    If you just need to display the HTML page with link support, you can use the JEditorPane with the content type as text/html. Look up the Java Tutorial on this site (http://java.sun.com/docs/books/tutorial/uiswing/components/text.html) and the API docs for details on how to use it.

  • Passing values to action form in struts using html:link tag in struts

    hi
    As we can post values to action form bean in struts using a <html:text> tag in side a form.
    Can the same be achieved by using a html:link attribute.
    If not then how can this be achieved (i.e. posting a form on click of a link and populating action form bean property for the same).
    thanx in advance.

    Crosspost:
    http://forum.java.sun.com/thread.jspa?threadID=5244035&tstart=0

  • Open a JspDynPage from a html link

    I would like to link a jps to the JspDynPage. I think that it would be able to do it through the "pcd". For example:
    - I have the SAP customer login screen (original) and i want to add a "link" (Forgotten PIN) to link with the JspDynPage (Java controller).
    Is it possible to do it? Does anyone know how? Do i go in right way?
    Thanks in advance.

    The code was lightsout.class, not #.class...
    I just want an HTML link to open a JAVA JFrame. Would a button work instead of an HTML link? Here's the beginning/initialization of my JFrame:
    public lightsout() {
              frame = new JFrame("LightsOut");
              frame.setSize(new Dimension(700, 700));
              frame.setTitle("Lights Out!");
              frame.setLocation(50, 50);
              frame.setResizable(false);
              japplet.setFocusable(false);
              frame.setAlwaysOnTop(true);
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              int height = screenSize.height;
              int width = screenSize.width;
              frame.setLocationRelativeTo(null);
              frame.setLayout(new BorderLayout());
              centerPanel = new JPanel(new GridLayout(5, 5));

  • How to run .html file from .java file..?

    Hi All,
    I was just trying as mentioned in the subject of how to run an html file from a java file.We have runtime class which inturn is having exec method which returns process but it supports only .exe as an argument .Is there any way to do this???
    Thanks in advance.

    viswa07 wrote:
    You mean to say Desktop class in java...???I'm so sorry, I thought you knew enough Java to look up the API.
    [This link|http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html] might be more at your level.
    db

  • 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

  • html:link action="/...." not working

    hi eve,
    i am trying to add this line <html:link action="/prepareSimple"> then the following error is comming
    org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 39
    36:
    39:           <html:link action="/prepareSimple">
    40:           <img src="images/execute.gif" alt="" hspace="4" border="0" align="top" class="inline" />
    41:           </html:link>
    42:           <html:link action="/prepareSimple">Execute</html:link>
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:518)
         javax.servlet.ServletException: java.lang.NoClassDefFoundError
    ava.lang.NoClassDefFoundError
    my struts-config.xml is
    <action path="/processSimple"
                        type="examples.simple.ProcessSimpleAction"
                        name="simpleForm"
                        scope="request"
                        input="/jsp/simple/Simple.jsp"
                        validate="true">
                   <forward name="success" path="/jsp/simple/SimpleResults.jsp"/>
              </action>
    can someone help me where i am wrong????????????

    Try to add a type.
    See http://en.wikipedia.org/wiki/Favicon

  • Html:link submit and passing parameters

    I need to submit the form when the <html:link ..... > is clicked/pressed and also need to pass parameters.
    <jsp:useBean id="mapParams" class="java.util.HashMap"/>
    <c:set target="${mapParams}" property="theKey" value="${theValue}"/>
    <c:set target="${mapParams}" property="theKey1" value="${theValue1}"/>
    <html:link href="javascript:document.myform.submit()" name="mapParams" >
    <c:out value="${custItr.empName}"/>
    </html:link>
    When i click on the link getting javascript error which says "syntax error". when I remove the "name" attribute in <html:link> there is no error but I need to have the name attribute to pass the parameters.
    How to do both the submit and passing of parameters using <html:link>? Your help is appreciated.
    Thanks.

    Parameters can only be passed like that to an actual URL. eg http://localhost:8080/myApp/showEmployee?id=123&dept=Sales
    In this case, you are using the link tag to invoke javascript - not a url. URL Parameters don't apply to this string
    If you are indeed submitting a form, I would suggest that you instead go with putting hidden fields on the form to submit the value.
    Use <html:hidden>

  • Html:link action html:link on results page null

    I am sure that this is something simple and small but I have been banging my head against this problem for a while now.
    I am using the <html:link> tag on my index.jsp page activates an action, retrieves a result and forwards to the homePage.jsp. The home page has a tiles layout and the results are actually in homePage_lowerLeftLevel.jsp within the homePage.jsp. Below the results I have an <html:link> tag which is identical to the tag in the index.jsp but now instead of seeing the link there is [ServletException in:/pages/homePage_leftLowerLevel.jsp] null' and if I go back to the index.jsp I get the following error�
    java.lang.NullPointerException
         at org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:313)
         at index.jspService(index.jsp:29)
         [SRC:/index.jsp]
         at com.orionserver[Oracle Application Server Containers for J2EE 10g (10.1.2.2.0)].http.OrionHttpJspPage.service(OrionHttpJspPage.java:57)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:356)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:498)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:402)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.2.0)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.2.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:673)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.2.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:340)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.2.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.2.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.2.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.2.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    If this <html:link> tag is not on the results page the results display perfectly. Here is my code:
    ********index.jsp**************
    <%@ page language="java" %>
    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
    <h2 class="lowerColumnHeader">Statistics</h2>
    <table class="statisticsTable">
    <tr>
    <td>
    ICF Published Parcels:
    </td>
    <td class="results">
    <bean:write name="homePageForm" property="result" />
    </td>
    </tr>
    </table>
    <html:link page="/homePage.do?areaId=bcId">Click Me </html:link>
    *********homePage_lowerLeftLevel.jsp*************
    <%@ page language="java" %>
    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
    <h2 class="lowerColumnHeader">Statistics</h2>
    <table class="statisticsTable">
    <tr>
    <td>
    ICF Published Parcels:
    </td>
    <td class="results">
    <bean:write name="homePageForm" property="result" />
    </td>
    </tr>
    </table>
    <html:link page="/homePage.do?areaId=bcId">Click Me </html:link>
    *****************struts_config.xml**********************
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    under the License.
    -->
    <!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
    "http://struts.apache.org/dtds/struts-config_1_3.dtd">
    <struts-config>
    <form-beans>
    <form-bean name="homePageForm"
    type="ca.bc.gov.srm.app.pip.HomePageForm" />
    </form-beans>
    <global-exceptions>
    <!-- sample exception handler
    <exception
    key="expired.password"
    type="app.ExpiredPasswordException"
    path="/changePassword.jsp"/>
    end sample -->
    </global-exceptions>
    <global-forwards>
    <forward
    name="homepage"
    path="/homePage.do"/>
    </global-forwards>
    <action
    path="/homePage"
    name="homePageForm"
    type="ca.bc.gov.srm.app.pip.action.HomePageAction"
    scope="request"
    validate="false"
    input="/pages/homePage.jsp"/>
    </action-mappings>
    <message-resources parameter="MessageResources" />
    <plug-in className="org.apache.struts.tiles.TilesPlugin" >
    <set-property property="definitions-config"
    value="/WEB-INF/tiles-defs.xml" />
    <set-property property="moduleAware" value="true" />
    </plug-in>
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property
    property="pathnames"
    value="/org/apache/struts/validator/validator-rules.xml,
    /WEB-INF/validation.xml"/>
    </plug-in>
    </struts-config>
    Thank you very much for your help

    It should be used something like this!!!
    <html:link action="myStrutsAction" paramId="user" paramName="userName"/>if the userName attribute had the value "Bob" that would produce:
    http://struts.apache.org/struts-doc-1.2.x/userGuide/struts-html.html#link

  • 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

Maybe you are looking for