• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem with the jetty embedded server.

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic