index.html
<HTML>
<HEAD>
</HEAD>
<BODY>
<DIV STYLE="POSITION:ABSOLUTE; LEFT:10; TOP:10; WIDTH:480; HEIGHT:400;
BACKGROUND-COLOR:BLACK;"></DIV>
</BODY>
<SCRIPT>
<!--
var outString = "basic.jsp?x1=" + 10
outString += "&y1=" + 10
outString += "&x2=" + 100
outString += "&y2=" + 100
location.href = outString
// -->
</SCRIPT>
</HTML>
basic.jsp
<%@ page contentType="image/jpeg" import="java.io.*, java.awt.*, java.awt.image.*,com.sun.image.codec.jpeg.*" %>
<%
try {
int x1 = Integer.parseInt(request.getParameter("x1"));
int y1 = Integer.parseInt(request.getParameter("y1"));
int x2 = Integer.parseInt(request.getParameter("x2"));
int y2 = Integer.parseInt(request.getParameter("y2"));
BufferedImage image = new BufferedImage(480, 400, BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.drawLine(x1, y1, x2, y2);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(response.getOutputStream());
encoder.encode(image);
} catch (Exception e) {}
%>
Download: UsePassedInParameterToDrawJPEGImage.zip( 2 k)