<%@page import="com.google.zxing.client.j2se.MatrixToImageWriter"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<h1>Hello World!</h1>
<%@page language='java'%>
<%@page import="java.io.*,java.util.*,java.util.Hashtable,javax.imageio.*,com.google.zxing.*,com.google.zxing.client.*,com.google.zxing.common.*,com.google.zxing.qrcode.decoder.*"%>
<%
String qrCodeData = "Hello World!";
String filePath = "QRCode.png";
String charset = "UTF-8"; // or "ISO-8859-1"
Hashtable hintMap = new Hashtable();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
createQRCode(qrCodeData, filePath, charset, hintMap, 200, 200);
out.println("QR Code image created successfully!");
%>
<%!
public void createQRCode(String qrCodeData, String filePath,
String charset,Hashtable hintMap, int qrCodeheight, int qrCodewidth)
throws WriterException, IOException {
BitMatrix matrix = new MultiFormatWriter().encode(
new String(qrCodeData.getBytes(charset), charset),
BarcodeFormat.QR_CODE, qrCodewidth, qrCodeheight,hintMap);
MatrixToImageWriter.writeToFile(matrix, filePath.substring(filePath
.lastIndexOf('.') + 1), new File(filePath));
}
%>
</body>
</html>
This code generates QR image in tomcat\bin directory.I want to change the directory to location where jsp files present.So that I could display them in webpage Pls help...