Firstly, here is my html code :
and this following code is part of my servlet code :
public void doGet(HttpCardServletRequest req, HttpCardServletResponse resp)This is the capture of the result :
throws Exception {
try {
ByteString queryString = req.getQueryString();
if (queryString != null) {
byte[] hello = { 'h', 'e', 'l', 'l','o' ,' '};
ByteString temp=queryString.substring((short)5, queryString.length());
// set header
resp.setStatus(HttpCardServletResponse.SC_OK);
resp.setContentType(stringContainer
.getConstantString(HttpStringContainer.TEXT_PLAIN_KEY));
int length = hello.length+temp.length();
resp.setContentLength(length);
// write body
HttpCardServletOutputStream out = resp.getOutputStream();
out.write(hello,(short)0,(short)hello.length);
out.write(temp);
}
} catch (Exception e) {
resp.setStatus(HttpCardServletResponse.SC_BAD_REQUEST);
}
}
No comments:
Post a Comment