Created
July 1, 2011 10:15
-
-
Save theresajayne/1058233 to your computer and use it in GitHub Desktop.
context + class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> | |
<servlet> | |
<servlet-name>getcmyk</servlet-name> | |
<servlet-class>uk.co.inbrand.getcmyk.GetCMYK</servlet-class> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>getcmyk</servlet-name> | |
<url-pattern>/getcmyk/*</url-pattern> | |
<url-pattern>/*</url-pattern> | |
</servlet-mapping> | |
<session-config> | |
<session-timeout> | |
30 | |
</session-timeout> | |
</session-config> | |
<welcome-file-list> | |
<welcome-file>index.jsp</welcome-file> | |
</welcome-file-list> | |
</web-app> | |
class file | |
/* | |
* Take in RGB url on the input and convert it to CMYK returning it as a binary feed | |
*/ | |
package uk.co.inbrand.getcmyk; | |
import java.io.ByteArrayInputStream; | |
import java.io.IOException; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
/** | |
* | |
* @author Theresa | |
*/ | |
public class GetCMYK extends HttpServlet { | |
private String myurl = null; | |
public void get(HttpServletRequest request, HttpServletResponse response) { | |
//WE need to get the url in from the passed in parameters | |
myurl = request.getParameter("url"); | |
if (myurl==null ) { | |
System.err.println("No parameter passed"); | |
} | |
String profile="file://c:/inbrand-1.0/CMYK.pf"; | |
byte[] rgb = null; | |
try { | |
URL myurlUrl = new URL(myurl); | |
myurlUrl.getContent(); | |
myurlUrl.openConnection(); | |
ByteArrayInputStream instr = (ByteArrayInputStream)myurlUrl.openStream(); | |
instr.read(rgb); | |
CMYKSave save = new CMYKSave(); | |
save.getcmyk(profile, rgb); | |
}catch(MalformedURLException mue) { | |
} catch(IOException ioe) { | |
} | |
} | |
public void post(HttpServletRequest request, HttpServletResponse response) { | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment