Install Spring IDE for Eclipse 3.4

 Installing Spring IDE on Eclipse 3.4 (RC1) was not quite as straight forward as I thought it would have been, so here are a few more details on how to do it.

 

  1. Help->Software Update
  2. Click Available Software tab
  3. Click Add Site
  4. Enter http://springide.org/updatesite
  5. Click checkbox next to http://springide.org/updatesite to expand.
  6. Click checkbox to uncheck, then click again to check parent and children [Eclipse bug 232112].
  7. Click Install
  8. Software validity warning message will come up - click Yes
  9. Resolving dependencies will moan with:

    (Spring IDE Bean Support (required),Spring IDE Dependencies (only for Eclipse 3.2.x),Spring IDE OSGi Extension (optional),Spring IDE Web Flow Extension (optional),Spring IDE Security Extension (optional),Spring IDE AOP Extension (optional),Spring IDE JavaConfig Extension (optional),Spring IDE Autowire Extension (optional),Spring IDE Mylyn Integration,Spring IDE AJDT Integration (optional),Spring IDE Security Extension Developer Resources,Spring IDE Autowire Extension Developer Resources,Spring IDE AOP Developer Resources,Spring IDE OSGi Extension Developer Resources,Spring IDE Webflow Developer Resources,Spring IDE Mylyn Integration Sources,Spring IDE JavaConfig Developer Resources,Spring IDE Sources,Spring IDE AOP Developer Resources) will be ignored.

  10. Uncheck Spring IDE Dependencies (only for Eclipse 3.2.x)
  11. Screen will re-calculate successfully and the Finish button will appear, click it

All is good in the world.

Keywords:

Filed Under: Eclipse · Spring

Eclipse 3.4 Ganymede and Spring IDE 2.0.6

To install Spring IDE 2.0.6 into Eclipse 3.4 Ganymede you need to switch off the Mylyn integration (as per the instructions) and remove the Eclipse 3.2 dependency.

From a clean install of Eclipse 3.4 Ganymede:

  1. From the menu: Help->Software Updates
  2. Click Add site…
  3. Enter the the Spring IDE update site url: http://springide.org/updatesite/site.xml
  4. Click Ok
  5. Check the box next to Sprint IDE Update Site
  6. Expand Sprint IDE Update Site
  7. Expand Dependencies
  8. Uncheck Spring IDE Dependencies (only for Eclipse 3.2.x)
  9. Expand Integrations
  10. Uncheck Spring Mylyn Integration (optional)
  11. Click Install
  12. Screen will show no unresolved dependencies
  13. Click Next >
  14. Select I accept the terms of the license agreement
  15. Click Finish

Keywords:

Filed Under: Eclipse · Spring

Configuring Eclipse to use Tomcat and the Spring Framework

There never seems to be enough documentation on how to create Spring Framework enabled projects in Eclipse. Spring is widely used for web applications so you need to know how to integrate Tomcat and Eclipse as well - so there is even less documentation! There follows below a step-by-step set of instructions to do just that.

I am not going to describe how to install the Java Runtime environment. If you need help with that, then maybe web services is not the career you should be focusing on ;) Needless to say it is a requirement of all the following technologies.

Installation
Windows is (not) funny about spaces in directory names so all the installations will be located under c:\java instead of c:\Program Files. You’ll save yourselves an enormous headache trying to figure out why Windows is not interpreting the command lines properly if you just remove the cause of the problem. Bloody Bill!

  1. Download Eclipse IDE for Java EE Developers 3.4 Ganymede from the downloads section of the Eclipse web site.
  2. Extract the eclipse-jee-ganymede-win32.zip into c:\Java\eclipse.
  3. Create a desktop shortcut to the Eclipse executable, for easy launching.
  4. Download Tomcat 6.x from the downloads section of the Tomcat web site. You will need to get the base (Core) pack and not the windows installer pack. The windows installer pack does not include some of the command-line scripts for launching Tomcat.
  5. Extract the apache-tomcat-6.0.18.zip into c:\java\apache-tomcat-6.0.18 then rename it to c:\java\tomcat.
  6. Launch Eclipse.
  7. On a new install of Eclipse it asks you where you want to put your workspace. We are going to place it in c:\java\workspace because the spaces issue will be a problem if it goes into c:\Documents and Settings\DavidQ\workspace.
  8. Next we are going to install our Spring IDE plugin, full instructions on how to do this are on my blog page entitled Eclipse 3.4 Ganymede and Spring IDE 2.0.6.
  9. After installation it says It is strongly recommended you restart your system for the changes to take effect. .. Restart now?, when it says system it means the eclipse workbench and not your whole computer, so click Yes.

Configure Tomcat inside Eclipse
Next we need to tell Eclipse about which Tomcat we are using and set up the integration.

  1. From the menu bar select Window->Preferences.
  2. The Preferences window will open. Expand Server.
  3. Highlight Runtime Environment. This is the place where you can tell Eclipse about where you put your Tomcat installation.
  4. Click Add.
  5. Expand Apache and select Apache Tomcat v6.0.
  6. Check the Create a new local server check box to create a new server in the Servers view.
  7. Click Next.
  8. Leave the Name of the server set to Apache Tomcat v6.0.
  9. Eclipse gives the option to download a version of Tomcat but it usually does not have the latest version (which is why we downloaded it separately). Click Browse and navigate to c:\java\tomcat and click Ok.
  10. Leave the JRE drop down set to Workbench default JRE.
  11. Click Finish.
  12. You are taken back to the Server Runtime Environments preference page so click Ok.
  13. A new project will have been created and if you go into the Servers view (in the bottom set of tabs), you will see a new server Apache Tomcat v6.0 at localhost.

Create project
There are several different types of project in Eclipse and we need the one that will allow us to integrate all the things we need.

  1. Select File->New->Dynamic Web Project
  2. Enter a Project name. Although you can have spaces, in my opinion, it’s best not to put any in. The project name becomes the directory name and for the same reason as above it’s a pain if there are spaces.
  3. The Target Runtime should already be set to Apache Tomcat v6.0.
  4. Also keep the Configuration set to Default Configuration for Apache Tomcat v6.0.
  5. Click Finish.
  6. In the Project Explorer, right click on the new project and select Spring Tools->Add Spring Project Nature.

Spring Web project and Tomcat project association
We must now associate the project with Tomcat.

  1. Make sure the Servers view is visible (in the bottom set of tabs). Highlight your new Spring Web project and drag it on to the Tomcat v6.0 Server at localhost entry in the Servers tab.
  2. We want to use the Tomcat server when we use our new project, so we can set the Server project to be a dependency of our new project. This will mean that when we open our project the Server project will open automatically.
  3. Right click on our project and select Properties.
  4. Select the Project References option and check the Servers project.
  5. Click Ok.

Keywords:

Filed Under: Eclipse · Spring · Tomcat

Struts 2.1.x + Tomcat 6.0 + Eclipse 3.5.0

This is more of a struts + eclipse + tomcat for beginners, as I am one myself. :) I spent one whole day on it, hope others don't have to....

I wanted to configure my system. Spent one whole day doing that, not a decent Help tutorial online. Finally I did manage something(Not the most ideal one, but it works), so here are the steps of what I did.

My Environment
Windows 7
Java 1.6

Step 1: The downloads
Download Struts 2.1.x : http://struts.apache.org/download.cgi
Download Eclipse(EE) 3.5.0 : http://www.eclipse.org/downloads/
Download Plugin : http://www.eclipsetotale.com/tomcatPlugin.html#A3 (com.sysdeo.eclipse.tomcat_3.2.1) This needs to be unzipped to your Eclipse Plugins directory.  Restart Eclipse, you may need a restart with -clean

Step 2: The easy part

Install Tomcat. The windows installer, auto installs. Just click next without changing too many
parameters if you are a novice.

Once it is done, just hit http://localhost:8080/
The page on the right hand should ideally appear. It it does not, it means that the installation is not
proper.

(For ease of understandability I use C:\)
Unzip Eclipse in C:\
Unzip Struts in C:\
Unzip the plugin downloaded and place the plugin (com.sysdeo.eclipse.tomcat_3.2.1) in C:\eclipse\plugins\ folder.

Step 3 : The beginning...
Start eclipse and create a New Project.
I named my Project as QBW.
Path : File --> New ---> Dynamic Web Project.

Step 4: Jars that matter
Then copy paste the following 6 jars in the lib folder.
Path : WebContent --> WEB-INF --> lib
  • commons-fileupload-1.2.1.jar
  • commons-logging-1.0.4.jar
  • freemarker-2.3.15.jar
  • ognl-2.7.3.jar
  • struts2-core-2.1.8.1.jar
  • xwork-core-2.1.6.jar

Also add the Struts jar files in Java EE Module Dependencies (Properties of project).

No need for them in the "Java Build Path" Libraries as External Jar dependencies.  


Step 5 (a): The XMLs
Replace the code in the web.xml with the following one.
Path : WebContent --> WEB-INF --> web.xml

<?xml version="1.0" encoding="UTF-8"?> <web-app 
id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 
<display-name>QBW : Welcomes You</display-name> <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>
Step 5 (b) : The Struts.xml

Create a new xml, called struts.xml and copy the following code in it.

Path : src --> struts.xml


<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts 
Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> 
<struts> <constant name="struts.enable.DynamicMethodInvocation" 
value="false" /> <constant name="struts.devMode" value="false" /> 
<package name="tutorial" namespace="/" extends="struts-default"> 
<action name="Welcome" class="QBW.Welcome"> 
<result>/Welcome.jsp</result> </action> </package> 
</struts>

Step 6: The Java Class

Put in the following piece of code in Welcome.java of the QBW package.

Path : src --> QBW--> Welcome.java


package QBW;
import com.opensymphony.xwork2.ActionSupport;
 
public class Welcome extends ActionSupport {
 
 
private static final long serialVersionUID = 1L;
private String message;
public String execute()
{
setMessage("Hello, Welcome to QBW... ");
return SUCCESS;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
Step 7: The JSP

This is the simplest part. Just create a JSP called Welcome.jsp

Path : WebContent --> Welcome.jsp

<%@ page contentType="text/html; charset=UTF-8" %> 
<%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> 
<title>QBW</title> </head> <body> Message from 
execute <br/><b><s:property value="message"/></b> The 
message in bold was set using the execute method of struts. </body> 
</html>

So now, your workspace will look approximately like this.



To run the project, click the Welcome.jsp then then debug.


Step 8: Screenshots speak louder than words.

Just have a look at the screenshots in my next post. Uploading them in this same blog will be cumbersome.... It deals with running the application on Tomcat server.


The most helpful links I came across


Struts 2.1.x has some really weirdo Jar dependencies. So import as few a jars as possible.

In case you run into something with conversion and codebehind, have a look at the the link below.

If you see:

WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:QBW' did not find a matching property.

The solution to this problem is very simple. Double click on your tomcat server. It will open the server configuration. Under server options check ‘Publish module contents to separate XML files’ checkbox. Restart your server. This time your page will come without any issues.

Keywords:

Filed Under:

Naming Standards

You should also be familiar with special naming conventions for Boolean and indexed properties. Many additional requirements exist, but they are less important for our situation. See java.sun.com/docs/books/tutorial/javabeans/index.html

Keywords:

Filed Under: Struts

Simple JavaBean

You can call a JavaBean a Bean and everyone will know what you’re talking about, as long as you’re not discussing coffee. The JavaBean documentation refers to the rules as design patterns. However, this term is more generally used to refer to design patterns such as the Model-View-Controller design pattern. Naming conventions is a more appropriate term.

As an example of the special Bean rules, let’s look at properties. A Bean’s properties that are exposed (public) are available only through the getter and setter methods, because the actual property definition is typically private (available to only the defining class). The properties follow the naming convention that the first letter of the property must be lowercase and any subsequent word in the name should start with a capital letter, such as mailingAddress. (We explain getters and setters after Listing 1-2.) Listing 1-2 is an example of a simple Bean.

Listing 1-2 Example of a Simple JavaBean

public class SimpleBean implements java.io.Serializable
{
private String name;
// public no-parameter constructor
public SimpleBean()
{
}
// getter method for name property
public String getName()
{
return name;
}
// setter method for name property
public void setName(String aName)
{
name = aName;
}
}

 

In this example, String is the type of property and name is the property. Methods that access or set a property are public (available to anyone using the Bean) and also use a certain naming convention. You name these methods as follows:

To get a property’s value, the method must begin with get followed by the property name with the first letter capitalized, as in public String getName();.These methods are called getters.

To set a property’s value, the method must begin with set followed by the property name with the first letter capitalized and the value to set the property to, as in public void setName(String theName);. These methods are called setters.

Keywords:

Filed Under: Struts

Struts Scope

Scope refers to an area in which an object (such as a Bean or any Java class) can be stored. Scopes differ based on the length of time stored objects are available for reference, as well as where the objects can be referenced from. In JSP and Struts, scope can be one of four values:

Page: Objects in the page scope are available only while the page is responding to the current request. After control leaves the current page, all objects stored in the page scope are destroyed.

Request: Objects in the request scope are available as long as the current request is being serviced. A request can be serviced from more than one page.

Session: The objects in the session scope last as long as the session exists. This could be until the user logs out and the session is destroyed or until the session times out due application has a unique session.

Application: The longest lasting scope is the application scope. As long as the application is running, the objects exist. Furthermore, objects in the application scope are available to all clients using the application. to inactivity. Each client using the Web.

Keywords:

Filed Under: Struts

JSP defines six types of tag elements:

Action: Follows the XML (eXtended Markup Language) format and always begins with <jsp:some action/>. It provides a way to add more functionality to JSP, such as finding or instantiating (creating) a JavaBean for use later. You see one example of an action tag in line 12 of the code in Listing 1-1.

Directive: A message to the Web container describing page properties, specifying tag libraries, or substituting text or code at translation time. The form is <%@ the directive %>. Listing 1-1 has directives on lines 1, 3, and 5.

Declaration: Declares one or more Java variables or methods that you can use later in your page. The tag has this form <%! declaration %>.

Expression: Defines a Java expression that is evaluated to a String. Its form is <%= expression %>.

Scriptlet: Inserts Java code into the page to perform some function not available with the other tag elements. Its form is <% java code %>.

Comment: A brief explanation of a line or lines of code by the developer. Comments have the form <%-- the comment --%>. Lines 2 and 4 in Listing 1-1 are examples of comments.

Listing 1-1 Sample JSP Page
1 <%@ page contentType=”text/html;charset=UTF-
8”language=”java” %>
2 <%-- JSTL tag libs --%>
3 <%@ taglib prefix=”fmt” uri=”/WEB-INF/fmt.tld” %>
4 <%-- Struts provided Taglibs --%>
5 <%@ taglib uri=”/WEB-INF/struts-html-el.tld”
prefix=”html” %>
6 <html:html locale=”true”/>
7 <head>
8 <fmt:setBundle basename=”ApplicationResources” />
9 <title><fmt:message key=”loggedin.title”/></title>
10 </head>
11 <body>
12 <jsp:useBean id=”polBean”
class=”com.othenos.purchasing.struts.POListBean”/>
13 <H2>
14 <fmt:message key=”loggedin.msg”>
15 <fmt:param value=’${polBean.userName}’ />
16 </fmt:message>
17 </H2>
18 </body>
19 </html>

Keywords:

Filed Under: Struts

What Is Jakarta Struts?

Java Servlets: Programs written in Java that reside on a Web server and respond to user requests

JavaServer Pages: A technology for generating Web pages with both static and dynamic content

JavaBeans: Components that follow specific rules, such as naming conventions

Business logic: The code that implements the functionality or rules of your specific application

 

Jakarta Struts uses a specific paradigm, or design pattern, to structure your application. You simply fill in the pieces of the structure. The design pattern is called Model-View-Controller (MVC). The MVC design pattern helps you organize the various pieces of the application puzzle for maximum efficiency and flexibility.

Keywords:

Filed Under: Struts

Struts Tutorials

TextBox widget example - adding any formatted HTML code to the widget.

Comment List

  • None

Month List