javabean调用的问题
javabean的程序如下:
package datastructure;
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class C1
{
private int pictureWidth=400;
private int pictureHeight=400;
public void draw(HttpServletResponse response)
{
response.reset();
response.setContentType( "image/png ");
BufferedImage image=new BufferedImage(pictureWidth,pictureHeight,BufferedImage.TYPE_INT_RGB);
Graphics2D g2d=image.createGraphics();
g2d.setPaint(Color.YELLOW);
g2d.fillRect(0, 0, pictureWidth, pictureHeight);
g2d.dispose();
ServletOutputStream sos=null;
try
{
sos=response.getOutputStream();
ImageIO.write(image, "PNG ",sos);
sos.close();
}
catch (
IOException ex) {
}
}
}
jsp的程序如下:
<%@ page language= "java " contentType= "text/html;charset=gb2312 "%>
<jsp:useBean id= "make " class= "datastructure.C1 " scope= "application "/>
<html>
<%
String k1=request.getParameter( "k1 ");
String k2=request.getParameter( "k2 ");
String k3=request.getParameter( "k3 ");
%>
<head>
<meta http-equiv= "Content-Type " content= "text/html;charset=gb2312 ">
</head>
<body bgcolor= "#FFCCFF ">
<%
if(k3!=null) make.draw(response);
else
{
out.println( " <div align= 'center '> ");
out.println( " <br> <br> <br> <br> <br> <br> <br> <br> <br> ");
out.println( " <font size= '12 ' color= '#0033CC '> <b> 数据结构在线演示 </b> </font> ");
out.println( " </div> ");
}
%>
</body>
</html>
有没有办法在上面的javabean中取得jsp中的k1和k2的?
------解决方案--------------------public void draw(HttpServletResponse response,String k1,String k2)
{
response.reset();
response.setContentType( "image/png ");
BufferedImage image=new BufferedImage(pictureWidth,pictureHeight,BufferedImage.TYPE_INT_RGB);
Graphics2D g2d=image.createGraphics();
g2d.setPaint(Color.YELLOW);