Meaningless Drivel is fun!*
The moose likes Other Java Products and Servers and the fly likes problem with the jetty embedded server. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "problem with the jetty embedded server." Watch "problem with the jetty embedded server." New topic
Author

problem with the jetty embedded server.

madura shantha
Greenhorn

Joined: Jun 04, 2008
Posts: 8
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...


Madura Shantha.
 
jQuery in Action, 2nd edition
 
subject: problem with the jetty embedded server.
 
Similar Threads
Working with JSP & Servlet paths
Problem download file.
Flushing response and then forwarding not working as expected
OSGi - Embedded Jetty Server - Servlet unable to get reference to Service Tracker
Jetty: wt are the reasons for the doPost method to be called twice?