1. petermr
  2. imageliberate

Commits

petermr  committed 272b5d3 Draft

added stub for server

  • Participants
  • Parent commits 6d2cec5
  • Branches default

Comments (0)

Files changed (4)

File pom.xml

View file
  • Ignore whitespace
     </repositories>
     
     <dependencies>
-    <!--  
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<version>3.0-alpha-1</version>
+		</dependency>
+                <!--  
         <dependency>
             <groupId>org.xml-cml</groupId>
             <artifactId>euclid-dev</artifactId>

File sample.war

  • Ignore whitespace
Binary file added.

File src/main/java/org/xmlcml/imagelib/ImageLibServlet.java

View file
  • Ignore whitespace
+package org.xmlcml.imagelib;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class ImageLibServlet extends HttpServlet {
+
+
+
+private String position = "NW";
+@Override
+    protected void doPost(HttpServletRequest request, HttpServletResponse response)
+        throws ServletException, IOException {
+ 
+	    String pos = request.getParameter("position");
+	    String url = request.getParameter("url");
+	}
+
+
+}
+

File src/main/java/org/xmlcml/imagelib/RequestParam.java

View file
  • Ignore whitespace
+package org.xmlcml.imagelib;
+
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class RequestParam extends HttpServlet {
+
+	private String firstName;
+	private String lastName;
+	
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+    throws IOException, ServletException
+    {
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+        out.println("<html>");
+        out.println("<head>");
+        out.println("<title>Request Parameters Example</title>");
+        out.println("</head>");
+        out.println("<body>");
+        out.println("<h3>Request Parameters Example</h3>");
+        out.println("Parameters in this request:<br>");
+        if (firstName != null || lastName != null) {
+            out.println("First Name:");
+            out.println(" = " + filter(firstName) + "<br>");
+            out.println("Last Name:");
+            out.println(" = " + filter(lastName));
+        } else {
+            out.println("No Parameters, Please enter some");
+        }
+        out.println("<P>");
+        out.print("<form action=\"");
+        out.print("RequestParamExample\" ");
+        out.println("method=POST>");
+        out.println("First Name:");
+        out.println("<input type=text size=20 name=firstname>");
+        out.println("<br>");
+        out.println("Last Name:");
+        out.println("<input type=text size=20 name=lastname>");
+        out.println("<br>");
+        out.println("<input type=submit>");
+        out.println("</form>");
+        out.println("</body>");
+        out.println("</html>");
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response)
+    throws IOException, ServletException
+    {
+        doGet(request, response);
+    }
+    
+    /**
+     * Filter the specified message string for characters that are sensitive
+     * in HTML.  This avoids potential attacks caused by including JavaScript
+     * codes in the request URL that is often reported in error messages.
+     *
+     * @param message The message string to be filtered
+     */
+    public static String filter(String message) {
+
+        if (message == null)
+            return (null);
+
+        char content[] = new char[message.length()];
+        message.getChars(0, message.length(), content, 0);
+        StringBuffer result = new StringBuffer(content.length + 50);
+        for (int i = 0; i < content.length; i++) {
+            switch (content[i]) {
+            case '<':
+                result.append("&lt;");
+                break;
+            case '>':
+                result.append("&gt;");
+                break;
+            case '&':
+                result.append("&amp;");
+                break;
+            case '"':
+                result.append("&quot;");
+                break;
+            default:
+                result.append(content[i]);
+            }
+        }
+        return (result.toString());
+
+    }
+
+}