3

I want make permanent redirect from http:// myurl to https:// myurl, but in Jetty I find only MovedContextHandler, with it I can redirect only context path, for examnple from myurl/bla to myurl/bla/bla

<Configure class="org.mortbay.jetty.handler.MovedContextHandler">
  <Set name="contextPath">/bla</Set>
  <Set name="newContextURL">/bla/bla</Set>
  <Set name="permanent">true</Set>
  <Set name="discardPathInfo">false</Set>
  <Set name="discardQuery">false</Set>
</Configure>

but how can I work with prefix of url?

1
  • Duplicate of this
    – Oli
    Dec 16, 2013 at 13:15

1 Answer 1

6

Best handled in your /WEB-INF/web.xml

<web-app>
  ...
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Everything in the webapp</web-resource-name>
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
      <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
</web-app>
3
  • @joakim-erdfelt Is the use of a SecureRequestCustomizer recommended when Jetty sees a 403 !SECURE error? See serverfault.com/a/575126 I currently have only static content.
    – gouessej
    Dec 20, 2016 at 9:43
  • @gouessej SecureRequestCustomizer is needed to trigger the "is secure" check on Jetty 9+ if you intend to redirect from a Jetty terminated SSL/TLS (https) to (http). But more importantly is the requirement for a properly configured HttpConfiguration (as the redirect uses that information to perform the redirect) on your SSL/TLS (https) ServerConnectors Dec 20, 2016 at 13:11
  • How to do it programmatically for a specific context handler? Dec 26, 2020 at 7:26

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.