title: embedded jetty server in a exploded war
body: <p>After successfully able to run a WAR through jetty, I am trying to embed jetty server into my web-application. It is a normal java application consisting servlet. I have used exploded WAR directory (WARless). </p>
  
  <p>But I get the following exception.</p>
  
  <pre><code>    2014-02-22 16:27:08.271:INFO:oejw.StandardDescriptorProcessor:NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet
      2014-02-22 16:27:08.319:WARN:oejs.Holder:
      java.lang.ClassNotFoundException: ClientServlet
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:421)
      at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:383)
      at org.eclipse.jetty.util.Loader.loadClass(Loader.java:100)
      at org.eclipse.jetty.util.Loader.loadClass(Loader.java:79)
      at org.eclipse.jetty.servlet.Holder.doStart(Holder.java:107)
      at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:298)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
      at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:791)
      at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
      at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
      at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
      at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
      at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
      at org.eclipse.jetty.server.Server.doStart(Server.java:282)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
      at com.jetty.RunJetty.main(RunJetty.java:24)
      2014-02-22 16:27:08.321:WARN:/:unavailable
  </code></pre>
  
  <p>Embedded jetty Server code</p>
  
  <pre><code>    package com.jetty;
  
      import org.eclipse.jetty.server.Server;
      import org.eclipse.jetty.webapp.WebAppContext;
  
      public class RunJetty {
  
      public RunJetty() {
      }
      public static void main(String[] args) {
      Server server=new Server(8080);
      WebAppContext wac = new WebAppContext();
      wac.setResourceBase("C:/Users/User/j2ee/workspace/CLient1");
      wac.setDescriptor("C:/Users/User/j2ee/workspace/CLient1/WebContent/WEB-INF/web.xml");
      wac.setContextPath("/");
      wac.setParentLoaderPriority(true);
      server.setHandler(wac);
      try {
          server.start();
          server.join();
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      }
  
      }
  </code></pre>
  
  <p>Servlet Code</p>
  
  <pre><code>    package com.jetty;
  
      import java.io.IOException;
  
      import javax.servlet.ServletException;
      import javax.servlet.http.HttpServlet;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
  
      import org.omg.CORBA.RepositoryIdHelper;
  
      public class ClientServlet extends HttpServlet {
  
      private static final long serialVersionUID = 8120079003868426157L;
      private String greeting="Hello World";
  
      public ClientServlet(){}
      public ClientServlet(String greeting)
      {
      this.greeting=greeting;
      }
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
      {
      response.setContentType("text/html");
      response.setStatus(HttpServletResponse.SC_OK);
      response.getWriter().println("&lt;h1&gt;"+greeting+"&lt;/h1&gt;");
  
      }
  
      }
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
      &lt;display-name&gt;kajh&lt;/display-name&gt;
  
      &lt;servlet&gt;
      &lt;description&gt;&lt;/description&gt;
      &lt;display-name&gt;ClientServlet&lt;/display-name&gt;
      &lt;servlet-name&gt;ClientServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;ClientServlet&lt;/servlet-class&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;ClientServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/ClientServlet&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;/web-app&gt;
  </code></pre>
  
  <p>Additionally, I want to use response.sendRedirect in my servlet. Something like,</p>
  
  <pre><code>      public class ClientServlet extends HttpServlet {
  
  /**
   * 
   */
  private static final long serialVersionUID = 8120079003868426157L;
  private String greeting="Hello World";
  
  public ClientServlet(){}
  public ClientServlet(String greeting)
  {
      this.greeting=greeting;
  }
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  {
      response.setContentType("text/html");
      response.sendRedirect("http://localhost:8080/CLient1/index.html");
  
  }
  }
  </code></pre>
  
  <p>Please help! I am stuck on this like forever.
  Thank you in advance!</p>
  
  <p>Also I am adding the folder structure of my application to have a better understanding</p>
  
  <p><img src="https://i.stack.imgur.com/a5OSM.png" alt="enter image description here"></p>