Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with the jetty embedded server.

 
madura shantha
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a problem of the jetty embedded server with the servlets. First I start the jetty embedded server and sends a request to the server. In the server, a servlet is running and according to the request,the request is forward to a jsp by the servlet. The problem is, when I am doing this, it gaves an exception. It comes from the place where I forward the request from the servlet to the jsp.

Here is the doPost method in the servlet code.

protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException {

String requestXml = createRequestXml(request);

for (int i = 0; i < ecgsRequests.length; i++) {
String ecgsRequest = ecgsRequests[i];
if (requestXml.indexOf(ecgsRequest) != -1) {
String forwardUrl =
"/WEB-INF/jsp/response/" +
forwardMappings.get(ecgsRequest);//this is where the exception comes.
try {
request.setAttribute("xml", requestXml);
request.getRequestDispatcher(forwardUrl)
.forward(request, response);
} catch (ServletException e) {
response.sendError(
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
}
}
============================================================================

And here is the place where I have the server code.

server = new Server();
SocketListener listener = new SocketListener();
listener.setPort(8080);
server.addListener(listener);

WebApplicationContext webappcontext = new WebApplicationContext();
webappcontext.setContextPath("/");
webappcontext.setWAR("/home/madura/simulator.war");
WebApplicationHandler webApplicationHandler = new WebApplicationHandler();
webappcontext.addHandler(webApplicationHandler);
webappcontext.addHandler(new ResourceHandler() );
server.addContext(webappcontext);
server.start();
=============================================================================

This is the client who calls the server.

client = new HttpClient();

method = new PostMethod("http://192.168.0.233:8080/myapp");
header = new Header("content-type", "text/xml");
method.setRequestHeader(header);
RequestEntity requestEntity = new StringRequestEntity(toSent, "text/xml", "ISO-8859-1");//toSent is the //String to be sent.
method.setRequestEntity(requestEntity);
int statusCode = client.executeMethod(method);
==============================================================================

Can any one help me?
thanks in advance.

Madura...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic