Java Servlet and JSP/JSF Help/Guidance - eclipse

I've had very limited exposure to Java Web development side and suddenly been asked to work on a web application and learn to maintain it. I’m struggling to setup an environment to be able to test and debug existing code given to me.
I'm on windows XP. Using Eclipse and Tomcat 5.
The web app they've dumped at me has the following structure:
Parent_directory
|- src
|- mainapp
|- model
|- AssignT.java
|- LeavePerm.java
|- Invoice.java
|- ....
|- util
|- Dates.java
|- reports.java
|- .....
|- application.properties
|- DB.properties
|- log.properties
|- email.properties
|- ......
|- Webroot
|-images
|- 1.png
|- ......
|-jsp
|- index.jsp
|- email.jsp
|- assign.jsp
|- leave.jsp
|- .....
|-META-INF
|- context.xml
|- MAINFEST.MF
|-Scripts
|- display.js
|- info.js
|- dates.js
|-WEB-INF
|- classes
|- {EMPTY}
|- lib
|- {MANY .jar files}
|- faces.config.mex
|- faces.config.xml
|- web.xml
The web application is working but minor modifications need to be made hence why I need to be able to setup an environments with eclipse and tomcat 5 to be able to make those changes and test.
Having installed tomcat and tomcat eclipse plugin I've added the tomcat server in server tab so eclipse knows where tomcat is and able to start/stop it but cannot get it to load the above imported project and run it. Trying the "Add or Remove" option on the server tells me "there are no resources that can be added".
I would appreciate any help or guidance.
Thank you

Did you download package labelled "Eclipse for Java EE Developers"? If so, then it contains WTP and make sure the project as the facet "Dynamic Web Module" selected.
In eclipse Facets are used as markers for enabling user interface
elements.
How to activate a Facets:
Not a faceted project then go in Project > Properties > Project Facets Click on "Convert to faceted form...".
Already faceted project go in Project > Properties > Project Facets Select "Dynamic Web Module" with the proper version 2.3 or 2.5.
After you should be able to add the project to the tomcat server in the server tab.
More information on Dynamic Web projects and applications.

Related

How do I include and access package resources?

I have this folder structure:
my-package -
|- src/mypackage
|- resources/some-resources
|- setup.py
|- setup.cfg
I want to load some-resources from within mypackage. How do I do this?
I have read online I should update my setup.py to include:
setup(
...
package_data={"": ["resources"]},
include_package_data=True,
...
)
And that I should then be able to use pkg_resources to access my resource folder. But the examples seem like they are incomplete, e.g. pkg_resources.resource_listdir("mypackage", "") (one suggestion) just lists the python files in mypackage. So to reiterate - how do I include resources in my package, and then access them from my code?

Eclipse 2020-09 (4.17.0) on OS X 10.13 keeps wanting me to put .gitignore and .DS_store on the path

I just upgraded to Eclipse 2020-09 (4.17.0) on OS X 10.13.
I have a large existing repository of java projects and I've installed the javascript and GWT plugins for Eclipse.
The problem is this: whenever I do almost anything (ex. save a file I'm working on), I get an error:
An error has occurred. See error log for more details. Path must include project and resource name: /.gitignore
specifically, the error comes from jface:
Problems occurred when invoking code from plug-in: "org.eclipse.jface".
the top of the error code is:
java.lang.IllegalArgumentException: Path must include project and resource name: /.gitignore
at org.eclipse.core.runtime.Assert.isLegal(Assert.java:66)
at org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:2128)
at org.eclipse.core.internal.resources.Container.getFile(Container.java:196)
at org.eclipse.egit.ui.internal.staging.StagingViewContentProvider.getFile(StagingViewContentProvider.java:139)
at org.eclipse.egit.ui.internal.staging.StagingEntry.getFile(StagingEntry.java:213)
at org.eclipse.egit.ui.internal.staging.StagingEntry.getProblemSeverity(StagingEntry.java:244)
at org.eclipse.egit.ui.internal.decorators.ProblemLabelDecorator.decorateImage(ProblemLabelDecorator.java:84)
at org.eclipse.jface.viewers.DecoratingLabelProvider.getImage(DecoratingLabelProvider.java:101)
But, there's a .gitignore in both the repo root and the project root and the project path settings are:
PARENT_LOC /Users/brian/git/JavaCodeFromSVN
PROJECT_LOC /Users/brian/git/JavaCodeFromSVN/jsAipotu
WORKSPACE_LOC /Users/brian/git/JavaCodeFromSVN
So I can't figure out what the problem is or how to fix it.
I can work in eclipse but it's really annoying to get these messages all the time.
I'm sure it's something obvious but I'm just not seeing it.
Might anyone be able to help? It seems that every time I upgrade Eclipse, it's a headache of one kind or another. Perhaps, someday, I'll learn my lesson and not upgrade :(
thanks
Brian
I think I may have fixed the problem. Here's what I did that made this go away.
Right-click the project: Team -> advanced -> Clean... and let it clean all it found (lots of .gitignores etc)
At that point, I was getting warnings about .DS_Store pretty consistently.
I followed the directions at https://intellipaat.com/community/9089/how-can-i-remove-dsstore-files-from-a-git-repository-gitignore-dsstore (By Debashis Borgohain)
they are:
Remove existing .DS_Store files from the repo. In the top level repo directory:
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
Create or update the .gitignore file at the top of the repo to contain a listing for .DS_Store. WHen set like this, even if Mac OS re-creates the .DS_Store files, they will be ignored by git when you commit changes, etc. Here is one way:
echo .DS_Store >> .gitignore
Commit the revised .gitignore
git add .gitignore
git commit -m '.DS_Store banished!'
to get rid of all the .DS_Store files, tell git to ignore them, and now it seems happy.
I got this error because I have a Maven project with sub-projects, and I made my Maven (base) project folder equal to the workspace folder:
πŸ“ eclipse-workspace = maven base project folder = root of Git repo
+-- πŸ“ subproject_1
| +-- πŸ“ pom.xml (of subproject)
+-- πŸ“ subproject_2
| +-- πŸ“ pom.xml (of subproject)
+-- πŸ“ pom.xml (of base project)
The first error was, that the base project could not be imported as a project. I thought this was meaningless, since the base project doesn’t contain code in my case, it is only a container. However, it seems Eclipse requires the base project to be a folder in the workspace:
πŸ“ eclipse-workspace
+-- πŸ“ project (base project) = root of Git repo
+-- πŸ“ subproject_1
| +-- πŸ“ pom.xml (of subproject)
+-- πŸ“ subproject_2
| +-- πŸ“ pom.xml (of subproject)
+-- πŸ“ pom.xml (of base project)

Can I specify the output folder for assets?

I have a project with this structure:
src
|- index.pug
| - layout
| |- index.less
| - scripts
| |- index.js
For now, when I run parcel build src/index.pug, all the files are bundled and I've got this on the distribution folder:
dist
|- index.html
|- index.12345.css
|- index.12345.js
When I was spected something like:
dist
|- index.html
|- layout
| |- index.12345.css
|- scripts
| |- index.12345.js
So, my question is: Can I specify the output path for my css, js and images using ParcelJS?
Parcel doesn't support this feature out of the box, but I've developed a plugin for it. Check it out https://www.npmjs.com/package/parcel-plugin-custom-dist-structure
It is suitable for all types of web/node development projects, it will generate the dist structure you specify while also handle your imports.
Let me know what you think!
With version 1 it's not supported. This is supposed to be available in version 2 through user plugins. See https://github.com/parcel-bundler/parcel/issues/233

Add Angular2 instructions to Netbeans IDE

I used to use Netbeans during my work. Now I want to start using Angular2.
I'm following tutorial from angular.io. I've created template HTML file with content (only relevant line):
<div *ngFor="let hero of heroes" (click)="gotoDetail(hero)">
And NB shows me errors about *ngFor and (click):
Attribute "*ngfor" is not realizable as XML 1.0. (Rule Category: Attributes)
Attribute "(click)" is not realizable as XML 1.0. (Rule Category: Attributes)
Attribute "*ngfor" not allowed on element "div" at this point. (Rule Category: Elements)
Attribute "(click)" not allowed on element "div" at this point. (Rule Category: Elements)
How can I teach NB that those are correct? I've already installed plugin to support TypeScript.
In my test project I downloaded node packages:
c:\proj> npm list --depth=0
angular2-quickstart#1.0.0 C:\a2
+-- angular2#2.0.0-beta.17
+-- concurrently#2.0.0
+-- es6-shim#0.35.0
+-- lite-server#2.2.0
+-- reflect-metadata#0.1.2
+-- rxjs#5.0.0-beta.6
+-- systemjs#0.19.26
+-- typescript#1.8.10
+-- typings#0.8.1
`-- zone.js#0.6.12
Unfortunately NetBeans does not support Angular 2 template syntax, so you will receive (wrong) warnings/errors and no codecompletion support.
You can use the TypeScript plugin and typings to get support for the TypeScript/JavaScript parts of the application. Feel free to open a NetBeans issue with the request, I will vote for it as well.
Edit:
There is already an issue filed to request that feature: https://netbeans.org/bugzilla/show_bug.cgi?id=257587 if you upvote it, it might get implemented.

How to change presentation of packages in Eclipse?

I need to work with Eclipse source. And I have many packages imported:
org.eclipse.core
org.eclipse.jdt
org.eclipse.jdt.core
org.eclipse.core.resources
etc
So I have all this packages in my project. How can I divide them by their tree? So they look like this in my project:
org
+
|- eclipse +
|- core
| +
| |- runtime
| |- resources
|- jdt
+
|- core
+
|- dom
Srinivas Thatiparthy's comment was close. There is an option "Package presentation" under another button that is next to the button similar to "-><-".