Resin Introduction
Resin requires a tux (tux.cs.drexel.edu) account in order to run java servlets. If you do not have one, but are taking a CS class this term, please email ihelp@drexel.edu
If are not a CS student but one is still required, then you may request one by emailing ihelp@drexel.edu
- Getting Started
- In
order to allow resin to manipulate your files your home directory must
be set to 755, if you are unfamiliar that lingo, a linux refresher might
be in order
- Kurt Schmidt has a good linux tutorial that may be found at: 1, 2, and 3
- The output of "ls -dal ~" should start with "drwxr-xr-x"
- It can be modified with "chmod 755 ~"
- Since this gives everyone read and execute permissions you may wish to lockdown the remainder of your directory (especially your coursework, but not your public_html)
- Create a "resin/WEB-INF" at the root of your home directory (~) and lock this down to 770 as it will contain coursework and perhaps passwords
- In
order to allow resin to manipulate your files your home directory must
be set to 755, if you are unfamiliar that lingo, a linux refresher might
be in order
- Anatomy of your WEB-INF directory
- tmp
- A directory that resin needs in order to compile and operate
- lib
- A directory to place extra external jars that you wish to be included
- classes
- The location for the code
- It would be wise to separate each distinct project into a separate sub-directory
- Your PGBundle will go at the root of this directory
- Format is key, single space, =, single space, value (no quotes)
- resin-web.xml
- The brains of the operation, more on this later
- tmp
- Permission Issues
- In order for resin to do anything, it must be able to read, write, and execute everything in your web-inf directory
- Read -> Read code
- Write -> Compile
- Execute -> Run the code
- I would not recommend that you give your directory over the resin group as it can hurt collaboration with other students as files can only have one group
- Instead you should give resin access to the directory via and ACL
DO NOT DO THIS AT THE ROOT OF YOUR HOME DIRECTORY, WHILE IT WILL WORK, RESIN CAN'T DESTROY WHAT IT CAN'T TOUCH
Will set up perms in your WEB-INF folder
Command to Set Resin User Perms
- This will give the user resin permission to RWX any files in the subdirectories
- This will carry over to all new files
'setfacl -d -R -m u:$USER:rwx,g:resin:rwx ~/resin/; setfacl -R -m u:$USER:rwx,g:resin:rwx ~/resin/'
- Running your java servlet
- Place your code in classes/SOME/OTHER/DIR
- Run "getfacl AFILE" to make sure that resin has permissions for all files
- If it doesn't have resin contained in the permissions, then you should rerun the setfacl command.
- ~/resin/WEB-INF/resin-web.xml
The web-app section will surround the rest of the code
resin-web.xml
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http:/java.sun.com/dtd/web-app_2_3.dtd">
......
</web-app>
servlet sections
Each servlet needs a name and somewhere to point the code
In the example below the code is located at classes/SOME/OTHER/DIR/SERVLET_MAIN.java
Servlet_MAIN.java will call the rest of the code
servlet formatting
<servlet>
<servlet-name>NAME_OF_YOUR_SERVLET</servlet-name>
<servlet-class>SOME.OTHER.DIR.SERVLET_MAIN</servlet-class>
</servlet>
servlet-mapping sections
- Each servlet needs to be mapped to a url so that the webserver can put that out there.
Each servlet mapping needs a name and a URL pattern.
servlet-mapping
<servlet-mapping>
<servlet-name>NAME_OF_YOUR_SERVLET</servlet-name>
<url-pattern>/WHAT_YOU_WOULD_LIKE_THE_URL_TO_BE</url-pattern>
</servlet-mapping>
- If I made a url-pattern "/test", then I would find the application on resin.cci.drexel.edu/~USER/test
- Keep in mind, you can have multiple servlets and mappings in each file.