facebook

Struts 2.X support?

  1. MyEclipse IDE
  2.  > 
  3. Installation, Configuration & Updates
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #302963 Reply

    dkuehner
    Member

    I just installed M8.0 on a new install of Eclipse 3.5.0. I tried adding struts 2 support, but I can’t seem to find any of the appropriate jars.

    I searched the eclipse directory and only found struts 1.3.8 jars.
    These were in …\eclipse\configuration\org.eclipse.osgi\bundles\199\1\.cp\data\1.3\lib
    and there were also jars – still version 3.1.8 in …\eclipse\configuration\org.eclipse.osgi\bundles\199\1\.cp\lib

    Shouldn’t the 2.x.x jars be installed somewhere?

    I didn’t use the full stack installer. I downloaded 3.5.0 Eclipse from the Eclipse site and did the M8.0 install from the “Install New Software” on the Help menu in Eclipse.

    #302965

    dkuehner
    Member

    Hmm for some reason that didn’t post properly. I’ll try again.

    I just installed M8.0 on a new install of Eclipse 3.5.0. I tried adding struts 2 support, but I can’t seem to find any of the appropriate jars.

    I searched the eclipse directory and only found struts 1.3.8 jars.
    These were in …\eclipse\configuration\org.eclipse.osgi\bundles\199\1\.cp\data\1.3\lib
    and there were also jars – still version 3.1.8 in …\eclipse\configuration\org.eclipse.osgi\bundles\199\1\.cp\lib

    Shouldn’t the 2.x.x jars be installed somewhere?

    I didn’t use the full stack installer. I downloaded 3.5.0 Eclipse from the Eclipse site and did the M8.0 install from the “Install New Software” on the Help menu in Eclipse.

    #302968

    dkuehner
    Member

    Still a problem with posting. I think there must be some special characters in my post. I’ll try again and remove what I think are the problems.

    I just installed M8.0 on a new install of Eclipse 3.5.0. I tried adding struts 2 support, but I can’t seem to find any of the appropriate jars.

    I searched the eclipse directory and only found struts 1.3.8 jars.
    These were in …\eclipse\configuration\org.eclipse.osgi\bundles\199\1\cp\data\1.3\lib
    and there were also jars – still version 3.1.8 in …\eclipse\configuration\org.eclipse.osgi\bundles\199\1\cp\lib

    Shouldn’t the 2.x.x jars be installed somewhere?

    I didn’t use the full stack installer. I downloaded 3.5.0 Eclipse from the Eclipse site and did the M8.0 install from the “Install New Software” on the Help menu in Eclipse.

    #302970

    dkuehner
    Member

    Still a problem with posting. I think there must be some special characters in my post. I’ll try again and remove what I think are the problems.

    I just installed M8.0 on a new install of Eclipse 3.5.0. I tried adding struts 2 support, but I can’t seem to find any of the appropriate jars.

    I searched the eclipse directory and only found struts 1.3.8 jars. Oddly they were in 2 places (and I won’t say where they are becasue the directory naming causes problems with posting)

    Shouldn’t the 2.x.x jars be installed somewhere?

    I didn’t use the full stack installer. I downloaded 3.5.0 Eclipse from the Eclipse site and did the M8.0 install from the “Install New Software” on the Help menu in Eclipse.

    #302999

    support-joy
    Member

    dkuehner,

    Can you try the following steps and let me know:

    1) Right click on the “Package Explorer”
    2) Select “New–>Web Project”. If you don’t find “Web Project” entry, click on Others and expand “MyEclipse–>Java Enterprise Projects”.
    You can now able to see “Web Project” entry.
    3) Enter Project name and select “J2EE Specification Level” radio button as “Java EE 5.0”.
    4) Click Finish.
    5) Now, right click on the project and go to “MyEclipse–>Add Struts Capabilities…”
    6) Under “Struts Specification”, you are able to see Struts 2.1.
    For your information, Struts 2 capabilities can only be added to JEE 5 web projects.
    Please let me know.

    #303004

    dkuehner
    Member

    I tried what you suggested, but nothing changes in my project after step 6.

    For instance, /WEB-INF/struts-config.xml was not added to my project, and when I look at the project properties under java build path, there are no struts jars added.

    When I do steps 5/6 but select struts 1.1, 1.2 or 1.3 it adds the struts-config and tld’s and jars to the project.

    It seems to me that the struts 2 support may not have been installed. When I did the M8.0 install, (using help -> install new software) I added the item “struts support for myeclipse”. Is there anything else I should have selected?

    #303051

    support-joy
    Member

    dkuehner,

    Let me clarify that the architecture of Struts1 and Struts2 is entirely different. You don’t require to have tld files,Struts-config.xml file to work with Struts2 application.

    Struts2 supported libraries will be added if you select Struts2 core libraries(default libraries) while adding struts capabilities(Refer Struts capabilites image).

    You need to have one Xml Configuration File struts.xml to map between request and its corresponding action.

    Let me walk you through a sample Struts2 application –

    1) Create a web application with Java EE 5.0.
    2) Add Struts Capabilities with Struts2.1 specification.
    3) Edit Web.xml file under WebRoot>WEB-INF with the below entries

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <web-app version=”2.5″
    xmlns=”http://java.sun.com/xml/ns/javaee&#8221;
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
    xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd”&gt;
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    </web-app>
    4) Edit index.jsp file under WebRoot with the below entries

    <%@taglib uri=”/struts-tags” prefix=”s” %>

    <html>
    <head>
    <title>Hello World</title>
    </head>
    <body>
    <s:form action=”HelloWorld” >
    <s:textfield name=”userName” label=”User Name” />
    <s:submit />
    </s:form>
    </body>
    </html>
    5) Create HelloWorld.java by following below steps

    a) Right click on src and select New>Class
    b) Enter “com.genuitec” in Package
    c) Enter “HelloWorld” in Name
    d) Click Finish
    e) Edit the entire file with following entries

    package com.genuitec;
    public class HelloWorld {

    private String message;

    private String userName;

    public HelloWorld() {
    }

    public String execute() {
    setMessage(“Hello ” + getUserName());
    return “SUCCESS”;
    }

    public String getMessage() {
    return message;
    }

    public void setMessage(String message) {
    this.message = message;
    }

    public String getUserName() {
    return userName;
    }

    public void setUserName(String userName) {
    this.userName = userName;
    }

    6) Create success.jsp by following below steps

    a) Right click on WebRoot and select New>Other
    b) Enter “jsp” in Wizards and select “JSP(Basic templates)” under MyEclipse>Web
    c) Click Next
    d) Enter “success.jsp” in File name and click Next and Finish.
    e) Edit the entire file with following entries

    <%@taglib uri=”/struts-tags” prefix=”s” %>
    <html>
    <head>
    <title>Hello World</title>
    </head>
    <body>
    <h1><s:property value=”message” /></h1>
    </body>
    </html>

    Then deploy and run the application.

    Attachments:
    You must be logged in to view attached files.
    #303059

    dkuehner
    Member

    Joy

    Thank you very much for this very detailed response. I have been using struts for years and assumed (wrongly) that the 2.x upgrade would be similar to going from struts 1.1 to 1.2 or 1.2 to 1.3. These just required the replacement of the approriate jar and tld files and then one could just use the new features.

    I’ll have to do some prototyping to determine how to incorporate struts 2.x into my product – which is a reasonably large commercial application.

    Thank you again, and please assume that my problem is resolved.

    #303094

    support-joy
    Member

    You are welcome. 🙂

Viewing 9 posts - 1 through 9 (of 9 total)
Reply To: Struts 2.X support?

This topic is marked as closed to new replies, however your posting capabilities still allow you to do so.

You must be logged in to post in the forum log in