mirror of
				https://github.com/fooflington/wordsearch.git
				synced 2025-10-31 04:38:33 +00:00 
			
		
		
		
	working webapp
This commit is contained in:
		
							
								
								
									
										13
									
								
								war/WEB-INF/web.xml
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								war/WEB-INF/web.xml
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| <?xml version="1.0" encoding="ISO-8859-1" ?> | ||||
|  | ||||
| <web-app xmlns="http://java.sun.com/xml/ns/j2ee" | ||||
|     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" | ||||
|     version="2.4"> | ||||
|  | ||||
|     <display-name>Wordsearch creator</display-name> | ||||
|     <description> | ||||
| 	Wordsearch building app | ||||
|     </description> | ||||
|  | ||||
| </web-app>  | ||||
							
								
								
									
										52
									
								
								war/build.jsp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										52
									
								
								war/build.jsp
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| <html> | ||||
| <head> | ||||
| 	<title>Wordsearch builder</title> | ||||
| 	<style> | ||||
| 	table, th, td { | ||||
| 		border: 1px solid black; | ||||
| 		border-collapse: collapse; | ||||
| 		padding: 2px 4px; | ||||
| 	} | ||||
| 	</style> | ||||
| </head> | ||||
| <%@ page import="uk.org.mafoo.wordsearch.*" %> | ||||
| <%@ page import="java.util.*" %> | ||||
| <%@ page errorPage="error.jsp" %> | ||||
| <% | ||||
|  | ||||
| 	int height = Integer.parseInt(request.getParameter("height")); | ||||
| 	int width  = Integer.parseInt(request.getParameter("width")); | ||||
|  | ||||
| 	if (request.getParameter("words").length() > 2048) { throw new Exception("Input too large"); } | ||||
|  | ||||
| 	List<String> words = new ArrayList<String>(); | ||||
| 	for ( String line : request.getParameter("words").split("\r\n")) { | ||||
| 		words.add(line.trim()); | ||||
| 	} | ||||
|   	 | ||||
|   	char[][] grid = GridFactory.makeGrid(words, height, width); | ||||
| %> | ||||
| <body> | ||||
| <h1>Wordsearch builder</h1> | ||||
| <h2>Words</h2> | ||||
| <ul> | ||||
| <% for (String word : words) { %> | ||||
|    <li><%= word.trim() %></li> | ||||
| <% } %> | ||||
| </ul> | ||||
|  | ||||
| <h2>Grid</h2> | ||||
| <table style="font-family: monospace;"> | ||||
| <% for(char[] row : grid) { %> | ||||
| 	<tr> | ||||
| 		<% for(char c : row) { %> | ||||
| 		<td><%= c %></td> | ||||
| 		<% } %> | ||||
| 	</tr> | ||||
| <% } %> | ||||
| </table> | ||||
| <footer> | ||||
| 	Generated | ||||
| </footer> | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										6
									
								
								war/error.jsp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										6
									
								
								war/error.jsp
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| <HTML> | ||||
| <BODY> | ||||
| <%@ page isErrorPage="true" %> | ||||
| Error: <%= exception %> | ||||
| </BODY> | ||||
| </HTML> | ||||
							
								
								
									
										26
									
								
								war/index.jsp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										26
									
								
								war/index.jsp
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| <html> | ||||
| <head><title>Wordsearch builder</title></head> | ||||
| <body> | ||||
| <h1>Wordsearch builder</h1> | ||||
| <h2>Words</h2> | ||||
| <form action="build.jsp"> | ||||
| 	<textarea name="words" rows="10"> | ||||
| Kitchen | ||||
| Lounge | ||||
| Study | ||||
| Ballroom | ||||
| Conservatory | ||||
| Billiard Room | ||||
| Library | ||||
| Hall | ||||
| Dining Room | ||||
| 	</textarea> | ||||
| 	<br /> | ||||
| 	<input type="number" name="height" min="3" max="50" value="5" /> | ||||
| 	<input type="number" name="width" min="3" max="50" value="5" /> | ||||
| 	<input type="submit" value="Build!" /> | ||||
| </form> | ||||
|  | ||||
|  | ||||
| </body> | ||||
| </html> | ||||
		Reference in New Issue
	
	Block a user