• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Using Eclipse for Web App

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'd like to use Eclipse for developing a java web app, but I'm having trouble with a few things. I can't get the project to "add" a previously made directory to the eclipse web project for me to save jsp files in. I was able, however, to "add" the src directory to the project.

I've setup my directory structure on my server as follows:

WebApp/
| src/ <----- This folder has been "added" to the project as the "source" directory
| build/
| web-archives/
| | WEB-INF/
| | | classes/
| | | jsp/ <----- How can I "add" or have "access" to this directory via eclipse (and the respective web project) to save jsp files in?
| | | lib/
| | | web.xml

Thanks.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you created the directory outside of Eclipse you need to refresh the view (F5).

Other than that there's nothing special.
 
Dan King
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:If you created the directory outside of Eclipse you need to refresh the view (F5).

Other than that there's nothing special.



I did create the directory outside of eclipse, so I went ahead and refreshed; unfortunately eclipse deleted the entire directory structure on the server upon refreshing. Any idea why eclipse deleted the directory?

Below are the steps I took to create the project in eclipse, if I missed a step or performed a step incorrectly, please let me know.

1. File --> New --> Dynamic Web Project
2. In the "Contents" section, I unchecked "Use default" and browsed to the directory location on the server, where I previously created the relevant directories
3. In the "Web Module" configuration page, I changed the content directory to "web-archive" (It's a directory that holds all web related files; the entire directory can later be converted to a war file and deployed to an app server)
4. Clicked "Finish"


 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're deploying a war, or even possibly an exploded archive, it's going to delete the server dirs in the tomcat dir--you should be making those directories inside Eclipses webapp root (whatever that is) and it will be deployed along with your classes.
 
Dan King
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:If you're deploying a war, or even possibly an exploded archive, it's going to delete the server dirs in the tomcat dir--you should be making those directories inside Eclipses webapp root (whatever that is) and it will be deployed along with your classes.



In my first attempt, I made the directories (outside of eclipse) in accordance with ant build tool recommendations - so deployment could be handled via ant. However, just to make sure I understand, you're stating that rather than create the directory structure outside of eclipse, I should make the directory structure (and thus the project) within eclipse? Furthermore, if I were to create the directories through eclipse, would other users be able to access/modify the directory and it's files?

The end goal for me is simply to:
1. Create a central location (on a server) for the source code and web content that multiple users can access. At a later stage, I'd like to integrate svn.
2. Leverage eclipse's functionality to build the jsp and servlet files.
3. Use ant to compile/deploy the webapp (war).

I appreciate your help and patience with my questions.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ant doesn't recommend anything in regards to IDE integration. Right now it sounds like you're trying to create a shared directory structure that anybody can access, outside of your local IDE/harddrive/etc. This is a bad idea.

That aside, either Ant or Eclipse or both can handle compilation/deployment. In general I create Ant-ish (or Maven-ish) directory structures, then create an Eclipse project around it, modifying build/lib/etc. paths to match whatever the build file's structure is.

In your case you're creating a bucket of worms, because if anybody changes the files, assuming they don't trash somebody else's changes, you'll have to refresh your Eclipse view in order to pull them in. Trust me--you'll forget, and people's changes will be lost, overwritten, and so on.

Normally you'd have a source repo, update your *local* files with changes from there, compile and deploy *locally* (or deploy to your instance of the development container if it isn't local), and so on.
 
Dan King
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:
Right now it sounds like you're trying to create a shared directory structure that anybody can access, outside of your local IDE/harddrive/etc. This is a bad idea.


You're right, I was trying to create a shared directory structure that anybody could access with their own IDE. However, with that said, let me clarify what I'm trying to do.

I have web development experience with PHP and Python, and now I'm learning java web development; to that end I'd like to simulate a multiple developer environment so I can be comfortable with the process and tools (eclipse and ant). I thought I'd start with a shared directory and then move onto a svn repo. Note: since this is a practice environment, the only one accessing the shared directory or the repo would be me.

With php and python, the environment usually consisted of an svn server from which each team member could checkout a local copy and any commits made would via a hook update the checked-out code on the (development) web app server so we could see the changes immediately.

David Newton wrote:
That aside, either Ant or Eclipse or both can handle compilation/deployment. In general I create Ant-ish (or Maven-ish) directory structures, then create an Eclipse project around it, modifying build/lib/etc. paths to match whatever the build file's structure is.


What you've written above is exactly what I'm trying to do.

David Newton wrote:
In your case you're creating a bucket of worms, because if anybody changes the files, assuming they don't trash somebody else's changes, you'll have to refresh your Eclipse view in order to pull them in. Trust me--you'll forget, and people's changes will be lost, overwritten, and so on.

Normally you'd have a source repo, update your *local* files with changes from there, compile and deploy *locally* (or deploy to your instance of the development container if it isn't local), and so on.



From your experience, is it a more common practice during development to deploy locally or to an external instance of the app server?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Neither is more common. Well, in *my* experience it's been more common to deploy to a local server, but I've also worked in environments where there's a development box and each developer has their own instance of the server they can deploy to.

I don't see any point in creating a non-local source directory if you're the only one accessing it, particularly since you're going to have a repository at some point.
 
Dan King
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess it makes the most sense for me to use a local-source directory or go ahead and setup the repo now, rather than later.

However, I do have a couple of follow-up questions:

1. Since eclipse can compile and deploy code, when/where does it make sense to use Ant?
2. What's the logic behind deploying to a local or individual instance of an app server, rather than a consolidated app server? Wouldn't deploying to a consolidated app server make it easier to test/integrate code across dev teams and reduce the amount of code that each developer needs to store locally?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Q: Since eclipse can compile and deploy code, when/where does it make sense to use Ant?
A: The use of Ant allows cross-environment builds, including builds by a continuous integration server. IMO it's not a great idea to rely on an IDE build process, but some environments control the IDE used, so it might not be as important. But having a known way to completely reproduce all development steps is a big win.

Q: What's the logic behind deploying to a local or individual instance of an app server, rather than a consolidated app server?
A: Decreased resource contention.

Q: Wouldn't deploying to a consolidated app server make it easier to test/integrate code across dev teams and reduce the amount of code that each developer needs to store locally?
A: Not at all. Each developer has a complete local source tree--the deployment environment has nothing to do with that. Each developer keeps their code up-to-date from the repo--code is always being tested and integrated.

You might want to read up on development practices, much of this stuff is covered in greater detail than practical here--might as well get it all at once rather than piecemeal/willy-nilly.
 
Dan King
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for bearing through my questions. Can you suggest any reading materials that can help me better understand java development practices?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the pragmatic series has a lot of good info, contained in relatively short books. They have an SVN book that might clear up some issues.
 
Have you no shame? Have you no decency? Have you no tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic