Code Challenge for Ethic using Java Servlets
Code containss two projects
- Servlet with simple form for file upload
- FormMetrics to calculate the word count, character count and palindromes in a file
For Palindromes calculation, words with "," and "'" are allowed to be included in the search. However, words or phrases with special characters are excluded (@#$%^&*()). The code checks for single words, numbers and phrases that would be considered a palindrome. Search is performed sentence by sentence. Therefore, palindromes longer than a single sentence will not be checked.
Form currently submits using an ajax requests, but also has capability for traditional post requests.
Files uploaded must be text files and less than 512 MB.
External Libraries Used:
- JSTL - to use loop in frontend
- Apache Commons IO - to copy data from inputstream in backend
- Apache Commons Fileupload - to use Fileupload features in the backend server
- Google GSON - to create json for ajax requests
Code is written with Java 8 and uses Tomcat 9.0
To deploy:
- Ensure there is a user with manager-gui and manager-script roles on your tomcat server
- Update build.properties with the username and password of user above
- Run "ant" to build all necessary files
- Run "ant war" to make the war file
- Run "ant deploy" to deploy to the path /ethic
To Run Tests:
- Run "ant test"