title: Method to have both HTTPS and HTTP with embedded Spark server?
body: <p>I have small embedded server supporting HTTPS using Spark.  I also want to support/catch some HTTP calls; e.g. like a help page and some redirections.</p>
  
  <p>For example a help page:</p>
  
  <pre><code>  http://localhost:8088/help .... renders .... http::8088//localhost/help.html
  </code></pre>
  
  <p>or a login page:</p>
  
  <pre><code>  http://localhost::8088/login ... renders .... https::8089//localhost/login.html
  </code></pre>
  
  <p>I have progressed to the stage where I have an embedded server that responds to either HTTP xor HTTPS -- One or the other, not both together.  Is it possible to respond to both protocols with the same embedded Jetty (via Spark) server?  If not, is it feasible to run two Jetty servers in the same embedded application?  Can I run two Spark servers in the same application?  (I'm taking it as '<em>read</em>' that if Jetty won't do it asking Spark for that service will be a dead-end).</p>
  
  <p>My preferred answer would be if I can use my Spark server to listen and handle both protocols.  My investigation so far suggest that only one mode is possible, largely because Spark is actually a static library you can only set-one port; and you may only have one 'Spark' server.  Has anyone used the same port for both HTTP and HTTPS?  (That just doesn't seem 'good' to me).</p>
  
  <p>I did find Unit Test code that looked like it was using both protocols, <a href="https://github.com/perwendel/spark/blob/1ecd428c8e2e5b0d1b8f221e9bf9e82429bd73bb/src/test/java/spark/util/SparkTestUtil.java" rel="nofollow">TestSparkUtil</a> here:</p>
  
  <ul>
  <li><a href="https://github.com/perwendel/spark/blob/1ecd428c8e2e5b0d1b8f221e9bf9e82429bd73bb/src/test/java/spark/util/SparkTestUtil.java" rel="nofollow">https://github.com/perwendel/spark/src/test/java/spark/util/SparkTestUtil.java</a></li>
  </ul>
  
  <p>However that's testing the server and uses lots of deprecated API-s.  One final thought is, can I use a second (embedded) Jetty-only servlet to redirect HTTP calls to HTTPS?  Would you recommend that?</p>
  
  <p>I'm sure there's an elegant solution here.  Thanks in advance for your time to consider the questions framed herewithin.  </p>