Web tools platform wtp project


















You are forbidden only to repost the files of the tutorial and project without espress permission of the author. This tutorial is Java-, Tomcat- and Eclipse-centric. I make no apologies for that and it narrows my focus enough that I will succeed in what I'm trying to do. What is the utility of a tutorial on this topic when so many others have written one? The answer is this one is more recent than the others an advantage that will quickly fade and it's a place I will refer to personally for links to resources.

And I'll be trying to keep it up to date for my own purposes. If you question anything in here, I'd be glad to hear from you. Write me at [email protected]. Eclipse version update: The screen shots illustrating Eclipse installation are pre-Ganymede Europa. However, I have looked at Ganymede and find it little different from them. Another developer went through this tutorial with Ganymede.

Moreover, I have received positive comments on getting this working under Galileo and Helios. One such comment is reproduced in the Appendices. My first attempts at writing a servlet and a JavaServer Page went well because I deployed by hand the many files according to the instructions I was following.

I knew, however, that real web developers use Eclipse not only to write code and maintain project structure, but also to produce the deployment artifacts of their applications.

I found Eclipse rather intimidating the first few times I tried it. So, I sought out a tutorial to help me learn. Out of a tutorial I found on eclipse. I'm going to do some simple things here in this tutorial, show you step-by-step a working if trivial JEE application, then recommend a number of useful books see bibliography at end of tutorial you can invest in to go further.

I will also list useful links I've found or used in the preparation of this tutorial. I'm not teaching anything here, just showing how to get up and running so that you won't be slowed down by this in your effort to learn.

It's like a Westerner learning Chinese versus Italian: it's not so much the language itself that's hard, it's what you do the language in that presents the greater challenge. The concepts behind servlets and JavaServer Pages JSPs are pretty straightforward; the countless cool things that Eclipse does for you are mind-blowing. But, the interface is huge and sometimes unwieldy for the newcomer.

However, I'm going to try to pay equal attention to Windows in this tutorial. I wanted to set this tutorial up so that it doesn't interfere with anything you've got going elsewhere on your development host—including any of the software listed below. So, whatever you've got on your host will be ignored and we'll download everything from scratch, place and consume it from a single directory anywhere you like and have access to.

This tutorial assumes a fair command of HTML, web browsing and experience installing software on your platform. It also assumes at least a beginner's command of the Java programming language. Last, it assumes you'll be observing and learning JSP as we go, researching expressions on-line or in books. We use very basic JSP that, if you know Java, will not mystify you.

I work occasionally in Windows, but do little development there. Because it's my understanding that most Eclipse developers run on Windows, I'll follow along to mimic what I do under Linux—including separate installations for these software components so as not to interfere with what's installed already on the workstation.

I'll make comments on Windows issues as I go, but only where I observe that the procedure differs from Linux. Most of the screen shots will be done on Windows because I just happen to be writing this tutorial there, so if Windows is your home, I'm hoping you will never feel left out in here.

First, we'll download the Java Developer's Kit by clicking on the Java icon here. Then, you'll see a page similar to the one you see on the right anytime an image is small in the tutorial, you can click on it to see the image normal size. We're looking for the JDK mostly, which I've circled crudely in this illustration.

You've had experience with downloads before; they're more or less likely to meander through questions whose answers will help the web site tailor what you'll get to best fit your needs. Sun may want to know what platform and language for your download. The point is that by the time you read this, the exact steps to get this download and it's true for all the others we do in this tutorial too , things may have changed.

What we want is JDK 6 and Update 5 is proposed, something that changes every few weeks. As I'm using Firefox on both Linux and Windows, the dialog I get may give me the choice to save the file or execute it directly. I'm going to save it into a new directory I've prepared under my home directory, named tutorial , in which the workings of this whole tutorial will be isolated.

I'm careful here not to get jdk-6u5-linux-i If I wanted to develop using Java 4, for example because I needed my application to run on NetWare while Novell never released the Java 1. Note: On Windows, you'll need to decide where to put the downloaded file.

There I'm looking at the following. Forgive me, I'm an incurable command-line guy, so even on Windows, I've got a console window open with a command-line prompt:. I make this file executable on Linux: it's a self-extracting archive that will open and dump the contents into the current directory:.

The archive self-extracts, I answer an end-user license agreement which launches a browser for me to register with Sun. This is not necessary; just dismiss the browser. Then I have this:. To keep the clutter to a minimum, I'll remove the self-extracting archive. Here, Windows is different because it really wants to install something using Windows Installer, so I have to be very careful.

I follow the usual installer pattern taking defaults, but when I get to the dialog to the right where it reveals to me the installation path, I stop because I already have this JDK installed on my system and, for the purposes of this tutorial, I want the files to be dropped into my isolated directory. Also, because Windows installations work differently from Linux not creating a subdirectory , I have to create the jdk1. I did this by hand in the console window:. After clicking Next , the software installs.

At certain points during our use of Eclipse, we'll be navigating into this directory structure to find the JRE and a library or two. Now let's move on to the Tomcat installation. The Tomcat download is simpler. Scroll down until you see a list of binary distributions since we don't want to download and build the source code ourselves.

Note: Again, if you want to run an older Tomcat because your target platform cannot support a modern one, you'll want to be careful to get that version down from Apache prior to installing Eclipse. Ensure these are in sync instead of whatever you started with and all should work fine.

Tomcat 7 note: As of January, , there was still a bug in the interaction between Tomcat 7 and Eclipse. If you wish to use this version of Tomcat, you will want to peruse this discussion thread in the Eclipse web tools platform forum. For Linux, I want the tarball file ending in. I click on that link and Firefox offers to open or save it. This doesn't take long, but if I look too soon in my directory, I'll see multiple files as pieces are assembled.

In a few moments all will disappear leaving only:. I'm left with just the Tomcat directory named apache-tomcat On Windows, I want a. Navigating to it in the GUI as you have seen, I entered the. Then I right-clicked on the folder icon and chose Copy. I right-click in empty space in the File Explorer window and choose Paste as my way of extracting from the. Then I delete the. This is the result easier than doing another screen shot in File Explorer :.

Your first time on the Eclipse Download page can be bewildering. I'll make it easy. See the illustration here as to what to expect on the download page and choose the one circled in red. The Web Tools Platform WTP that is crucial to what we're doing here will come along for free, although not always the very latest one.

Never mind, the one you get might be more stable anyway. So, click on the Eclipse icon above to get started; follow the instructions you've just read in choosing which package. To the right of the package name, description with the fancy icon, we see offered downloads appropriate for Windows, Linux and Mac OS X. Here's where my advice to Macintosh afficionados no longer holds for what to download.

Click on the one appropriate for your host platform. Then pick a download mirror, ostensibly one from your or a nearby country. On Linux, the name of the tarball downloaded is eclipse-jee-europa-winter-linux-gtk.

This produces:. On Windows, the name of the file will be something like eclipse-jee-europa-winter-win Basically, it gives you a lot of wizards and other help to develop your web application in as complete an environment as possible. It performs the complex deployment of your application. At long last our three pieces of software are downloaded and we're ready to launch Eclipse on our first project.

Now that Eclipse is installed, you'll want to launch it. Remember, you may have Eclipse installed elsewhere or this may be your first installation. Ensure that you get the correct one. I'm pretty certain that nothing I care about is stuck back on that version. At this point, we'll be working in Eclipse and platform differences are either very small or non-existent. We'll no longer separate instructions for Linux and Windows except for the odd observation.

With the Eclipse IDE launched from a fresh installation, you'll see the dialog box pictured below. We must choose a workspace, a directory into which all our Eclipse projects will be placed.

I'm just going to choose this tutorial subdirectory I've created. Click on the B rowse button and navigate to the directory just above tutorial. Click on tutorial , then click okay until you get the Eclipe IDE splash screen. To see what this looks like if you don't know, click here. Note that the splash screens look a bit different for Ganymede and Galileo.

At this point, we'll want to go directly into the workbench. Click the workbench button, the one at the right side of the window circled in red in the previous link to see the splash screen. The first thing to do is to set up certain preferences we'll have when working in Eclipse. Pull down the Window menu, choose Preferences Then, click on Installed JREs as you see in the graphic below. As noted earlier, I'm writing this tutorial and taking my screen shots on a Windows box.

However, I've also downloaded JDK 1. So, click Add Don't go down into it, but just click OK. After a few moments, you'll get. Click OK , then unclick the check box next to jdk 1. To see what the finished Installed JREs list looks like, click here. Next, scroll down the left pane of the Preferences dialog to expand the Server preference item.

Click on Installed Runtimes. Click Next , then Browse and then click not double-click on the apache-tomcat To see what the final Server preferences look like, click here. Within the context of this tutorial, where you've downloaded everything you need separately from anything you might installed otherwise, you might not have to worry about how some of your project preferences are set, but if you choose differently from the ones you use instead of those I'm showing here Java 1.

Click here if you wish to read about this or if you have trouble running the server later in the steps below. Now, we'll begin our project. Create a new Dynamic Web Project by right-clicking in the empty white space of the Poject Explorer view at the extreme left of the workbench, choosing New , then Dynamic Web Project.

Now, you'll see the a dialog box in which you can name the project, we're calling it wtp-tutorial. Click on Finish. Now we'll create our first JSP. If you need, you can see what this looks like by clicking here. Eclipse knows that the JSP file goes down under the WebContent subdirectory of the project and selects it when presenting you with the dialog box for naming this file.

We'll call it tutorial. Our project now has a JSP file with some default stuff in it. After expanding WebContent in the Project Explorer , we see that the JSP is under WebContent where it should be Tomcat looks for it there and the Edit view of the workbench is loaded up with it ready for modification.

As this JSP won't display much that we can recognize, let's make several modifications to it and I'm assuming here that you read and speak HTML fluently. If you don't understand these instructions, compare the new contents of tutorial. Edit the file to do the following things:. Next, let's get a Tomcat server up and running so that we can try out the JSP. Click on Server , then right-click in the large white space, choose New , then Server.

You should see the Apache Tomcat v6. Click Next and associate or add the wtp-tutorial project to this server's configured projects of which there are presently none. The red arrow demonstrates that we're essentially going to move wtp-tutorial from the list of available projects to the configured list.

We'll talk more about that later. For now, right-click on Republish and choose Publish. Before we can access our JSP remotely from a browser, we need to start the server. Select the Server view by clicking on the Server tab near the bottom of the workbench where we've just been working. Right-click on Stopped and choose Start. This is normal and indicates that the server has started up successfully.

Warning: I found on Linux that I had to close a browser window I had opened before starting the Tomcat server from Eclipse as it wasn't healthy. At this point, after all the software downloads, creating a project and a server, I have the following directories in my workarea as seen from a Windows command prompt and ls -al on Linux tells me I have the same thing :.

Now, you can write an entire web application using one or more JSPs only. In this tutorial, we'll strike a balance between the two although trivially since we're not really doing anything.

But why should we use both? There are good reasons and explaining them borders both on theory and religion. They are well tackled in real books on the subject that can do a better job than I see, for example, Marty Hall's volume 1 book in my bibliography which is also available free on-line; see chapter Consider yourself initiated on the topic.

It's time to move on. Before we create our servlet code, let's look at and plan our web presentation a little bit. Because we want to make at least trivial use of a lot of elements of JEE, we're going to present our user a form to fill out.

The results of the form will be sent to a servlet and then JSPs. Our form is simple: It will collect a greeting and a color. The greeting starts out with a default using a bean. We'll talk more about this in a moment. This is the result of the HTML form whose code follows. In Eclipse, you need only right-click on the wtp-tutorial project, choose New , Other I decided to use the GreetingBean because, at some point, I'll use the bean to provide persistence in the greeting.

Then, when I relaunch, I would get to reuse my same greeting. We create a bean because if, when validating the form's request on a more complicated form , we find something wrong, we'll have to redisplay it to get the bad fields corrected. Use the Kepler site. The URL you're using is not supposed to be used any more the timestamps you see are very old.

It's happened because you have already installed this package as i understand. So you just need to uncheck "Path feature for tests" at previous window. How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?

Collectives on Stack Overflow. Learn more. Asked 8 years, 5 months ago. Active 6 years, 3 months ago. Viewed 60k times. I tried to add WTP in already existing eclipse. For this I open Install Dialog in the following way. Why I am getting error? How can I fix this? Improve this question. Why do u select everything in the WTP.. For example uncheck the 'Patch feature for Tests" while installing and intall — saurav.

Installation was done successfully,but It's not allowing me to setting Apache Tomcat as a runtime target. It showing Static Web Project under Web folder. Add a comment.



0コメント

  • 1000 / 1000