How to configure Weblogic application Sever for Angular application











up vote
4
down vote

favorite
1












I have an Angular (6.1) application that is packed in a WAR (and EAR) file and should be deploy to a Weblogic (12c).

Based on this link all requests to the application (context root) should be routed to the index.html application file.



There some configuration examples in the documentation but non of them for an application server like WebLogic.
As it should be coupled with the application it shall go within the WAR and I thought of using the servlet mapping in the web.xml. I played around with it but don't get it working.
(internal server error, Not Found for other views than default ... even if I got it working with plain WAR in a tomcat, WebLogic refuses to do the same, ...)



Before putting there to much time in it - is this the right way?

If so, how would the correct mapping/pattern look like?

If not, what is the other way to have it configured within the WAR?










share|improve this question




























    up vote
    4
    down vote

    favorite
    1












    I have an Angular (6.1) application that is packed in a WAR (and EAR) file and should be deploy to a Weblogic (12c).

    Based on this link all requests to the application (context root) should be routed to the index.html application file.



    There some configuration examples in the documentation but non of them for an application server like WebLogic.
    As it should be coupled with the application it shall go within the WAR and I thought of using the servlet mapping in the web.xml. I played around with it but don't get it working.
    (internal server error, Not Found for other views than default ... even if I got it working with plain WAR in a tomcat, WebLogic refuses to do the same, ...)



    Before putting there to much time in it - is this the right way?

    If so, how would the correct mapping/pattern look like?

    If not, what is the other way to have it configured within the WAR?










    share|improve this question


























      up vote
      4
      down vote

      favorite
      1









      up vote
      4
      down vote

      favorite
      1






      1





      I have an Angular (6.1) application that is packed in a WAR (and EAR) file and should be deploy to a Weblogic (12c).

      Based on this link all requests to the application (context root) should be routed to the index.html application file.



      There some configuration examples in the documentation but non of them for an application server like WebLogic.
      As it should be coupled with the application it shall go within the WAR and I thought of using the servlet mapping in the web.xml. I played around with it but don't get it working.
      (internal server error, Not Found for other views than default ... even if I got it working with plain WAR in a tomcat, WebLogic refuses to do the same, ...)



      Before putting there to much time in it - is this the right way?

      If so, how would the correct mapping/pattern look like?

      If not, what is the other way to have it configured within the WAR?










      share|improve this question















      I have an Angular (6.1) application that is packed in a WAR (and EAR) file and should be deploy to a Weblogic (12c).

      Based on this link all requests to the application (context root) should be routed to the index.html application file.



      There some configuration examples in the documentation but non of them for an application server like WebLogic.
      As it should be coupled with the application it shall go within the WAR and I thought of using the servlet mapping in the web.xml. I played around with it but don't get it working.
      (internal server error, Not Found for other views than default ... even if I got it working with plain WAR in a tomcat, WebLogic refuses to do the same, ...)



      Before putting there to much time in it - is this the right way?

      If so, how would the correct mapping/pattern look like?

      If not, what is the other way to have it configured within the WAR?







      angular weblogic config






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 15:31









      Al Fahad

      735620




      735620










      asked Oct 31 at 17:17









      PaulEdison

      8410




      8410
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Use a servlet filter. If the request is a GET, and should be forwarded to index.html, then forward it to index.html. Otherwise, pass the request down the chain. Here's an example of such a filter. Of course, depending on the architecture of your application, the conditions could be different:



          @WebFilter(value = "/*")
          public class IndexFilter implements Filter {
          @Override
          public void doFilter(ServletRequest req,
          ServletResponse response,
          FilterChain chain) throws IOException, ServletException {
          HttpServletRequest request = (HttpServletRequest) req;
          if (mustForward(request)) {
          request.getRequestDispatcher("/index.html").forward(request, response);
          return;
          }

          chain.doFilter(request, response);
          }

          private boolean mustForward(HttpServletRequest request) {
          if (!request.getMethod().equals("GET")) {
          return false;
          }

          String uri = request.getRequestURI();

          return !(uri.startsWith("/api")
          || uri.endsWith(".js")
          || uri.endsWith(".css")
          || uri.startsWith("/index.html")
          || uri.endsWith(".ico")
          || uri.endsWith(".png")
          || uri.endsWith(".jpg")
          || uri.endsWith(".gif")
          || uri.endsWith(".eot")
          || uri.endsWith(".svg")
          || uri.endsWith(".woff2")
          || uri.endsWith(".ttf")
          || uri.endsWith(".woff");
          }

          @Override
          public void init(FilterConfig filterConfig) throws ServletException {
          // nothing to do
          }

          @Override
          public void destroy() {
          // nothing to do
          }
          }





          share|improve this answer





















          • I think that would be a valid idea - So I would have to extend the WAR by this filter. BUT from the link to the documentation it seems to me that EVERY request has to be redirected to the index.html BUT form code it seems that some extensions are not redirected - that seems to be absolutely correct for me as a *png should not be redirect to index.html ... just confuses me.
            – PaulEdison
            Nov 6 at 3:29











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53088876%2fhow-to-configure-weblogic-application-sever-for-angular-application%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Use a servlet filter. If the request is a GET, and should be forwarded to index.html, then forward it to index.html. Otherwise, pass the request down the chain. Here's an example of such a filter. Of course, depending on the architecture of your application, the conditions could be different:



          @WebFilter(value = "/*")
          public class IndexFilter implements Filter {
          @Override
          public void doFilter(ServletRequest req,
          ServletResponse response,
          FilterChain chain) throws IOException, ServletException {
          HttpServletRequest request = (HttpServletRequest) req;
          if (mustForward(request)) {
          request.getRequestDispatcher("/index.html").forward(request, response);
          return;
          }

          chain.doFilter(request, response);
          }

          private boolean mustForward(HttpServletRequest request) {
          if (!request.getMethod().equals("GET")) {
          return false;
          }

          String uri = request.getRequestURI();

          return !(uri.startsWith("/api")
          || uri.endsWith(".js")
          || uri.endsWith(".css")
          || uri.startsWith("/index.html")
          || uri.endsWith(".ico")
          || uri.endsWith(".png")
          || uri.endsWith(".jpg")
          || uri.endsWith(".gif")
          || uri.endsWith(".eot")
          || uri.endsWith(".svg")
          || uri.endsWith(".woff2")
          || uri.endsWith(".ttf")
          || uri.endsWith(".woff");
          }

          @Override
          public void init(FilterConfig filterConfig) throws ServletException {
          // nothing to do
          }

          @Override
          public void destroy() {
          // nothing to do
          }
          }





          share|improve this answer





















          • I think that would be a valid idea - So I would have to extend the WAR by this filter. BUT from the link to the documentation it seems to me that EVERY request has to be redirected to the index.html BUT form code it seems that some extensions are not redirected - that seems to be absolutely correct for me as a *png should not be redirect to index.html ... just confuses me.
            – PaulEdison
            Nov 6 at 3:29















          up vote
          0
          down vote













          Use a servlet filter. If the request is a GET, and should be forwarded to index.html, then forward it to index.html. Otherwise, pass the request down the chain. Here's an example of such a filter. Of course, depending on the architecture of your application, the conditions could be different:



          @WebFilter(value = "/*")
          public class IndexFilter implements Filter {
          @Override
          public void doFilter(ServletRequest req,
          ServletResponse response,
          FilterChain chain) throws IOException, ServletException {
          HttpServletRequest request = (HttpServletRequest) req;
          if (mustForward(request)) {
          request.getRequestDispatcher("/index.html").forward(request, response);
          return;
          }

          chain.doFilter(request, response);
          }

          private boolean mustForward(HttpServletRequest request) {
          if (!request.getMethod().equals("GET")) {
          return false;
          }

          String uri = request.getRequestURI();

          return !(uri.startsWith("/api")
          || uri.endsWith(".js")
          || uri.endsWith(".css")
          || uri.startsWith("/index.html")
          || uri.endsWith(".ico")
          || uri.endsWith(".png")
          || uri.endsWith(".jpg")
          || uri.endsWith(".gif")
          || uri.endsWith(".eot")
          || uri.endsWith(".svg")
          || uri.endsWith(".woff2")
          || uri.endsWith(".ttf")
          || uri.endsWith(".woff");
          }

          @Override
          public void init(FilterConfig filterConfig) throws ServletException {
          // nothing to do
          }

          @Override
          public void destroy() {
          // nothing to do
          }
          }





          share|improve this answer





















          • I think that would be a valid idea - So I would have to extend the WAR by this filter. BUT from the link to the documentation it seems to me that EVERY request has to be redirected to the index.html BUT form code it seems that some extensions are not redirected - that seems to be absolutely correct for me as a *png should not be redirect to index.html ... just confuses me.
            – PaulEdison
            Nov 6 at 3:29













          up vote
          0
          down vote










          up vote
          0
          down vote









          Use a servlet filter. If the request is a GET, and should be forwarded to index.html, then forward it to index.html. Otherwise, pass the request down the chain. Here's an example of such a filter. Of course, depending on the architecture of your application, the conditions could be different:



          @WebFilter(value = "/*")
          public class IndexFilter implements Filter {
          @Override
          public void doFilter(ServletRequest req,
          ServletResponse response,
          FilterChain chain) throws IOException, ServletException {
          HttpServletRequest request = (HttpServletRequest) req;
          if (mustForward(request)) {
          request.getRequestDispatcher("/index.html").forward(request, response);
          return;
          }

          chain.doFilter(request, response);
          }

          private boolean mustForward(HttpServletRequest request) {
          if (!request.getMethod().equals("GET")) {
          return false;
          }

          String uri = request.getRequestURI();

          return !(uri.startsWith("/api")
          || uri.endsWith(".js")
          || uri.endsWith(".css")
          || uri.startsWith("/index.html")
          || uri.endsWith(".ico")
          || uri.endsWith(".png")
          || uri.endsWith(".jpg")
          || uri.endsWith(".gif")
          || uri.endsWith(".eot")
          || uri.endsWith(".svg")
          || uri.endsWith(".woff2")
          || uri.endsWith(".ttf")
          || uri.endsWith(".woff");
          }

          @Override
          public void init(FilterConfig filterConfig) throws ServletException {
          // nothing to do
          }

          @Override
          public void destroy() {
          // nothing to do
          }
          }





          share|improve this answer












          Use a servlet filter. If the request is a GET, and should be forwarded to index.html, then forward it to index.html. Otherwise, pass the request down the chain. Here's an example of such a filter. Of course, depending on the architecture of your application, the conditions could be different:



          @WebFilter(value = "/*")
          public class IndexFilter implements Filter {
          @Override
          public void doFilter(ServletRequest req,
          ServletResponse response,
          FilterChain chain) throws IOException, ServletException {
          HttpServletRequest request = (HttpServletRequest) req;
          if (mustForward(request)) {
          request.getRequestDispatcher("/index.html").forward(request, response);
          return;
          }

          chain.doFilter(request, response);
          }

          private boolean mustForward(HttpServletRequest request) {
          if (!request.getMethod().equals("GET")) {
          return false;
          }

          String uri = request.getRequestURI();

          return !(uri.startsWith("/api")
          || uri.endsWith(".js")
          || uri.endsWith(".css")
          || uri.startsWith("/index.html")
          || uri.endsWith(".ico")
          || uri.endsWith(".png")
          || uri.endsWith(".jpg")
          || uri.endsWith(".gif")
          || uri.endsWith(".eot")
          || uri.endsWith(".svg")
          || uri.endsWith(".woff2")
          || uri.endsWith(".ttf")
          || uri.endsWith(".woff");
          }

          @Override
          public void init(FilterConfig filterConfig) throws ServletException {
          // nothing to do
          }

          @Override
          public void destroy() {
          // nothing to do
          }
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 3 at 17:02









          JB Nizet

          528k51853986




          528k51853986












          • I think that would be a valid idea - So I would have to extend the WAR by this filter. BUT from the link to the documentation it seems to me that EVERY request has to be redirected to the index.html BUT form code it seems that some extensions are not redirected - that seems to be absolutely correct for me as a *png should not be redirect to index.html ... just confuses me.
            – PaulEdison
            Nov 6 at 3:29


















          • I think that would be a valid idea - So I would have to extend the WAR by this filter. BUT from the link to the documentation it seems to me that EVERY request has to be redirected to the index.html BUT form code it seems that some extensions are not redirected - that seems to be absolutely correct for me as a *png should not be redirect to index.html ... just confuses me.
            – PaulEdison
            Nov 6 at 3:29
















          I think that would be a valid idea - So I would have to extend the WAR by this filter. BUT from the link to the documentation it seems to me that EVERY request has to be redirected to the index.html BUT form code it seems that some extensions are not redirected - that seems to be absolutely correct for me as a *png should not be redirect to index.html ... just confuses me.
          – PaulEdison
          Nov 6 at 3:29




          I think that would be a valid idea - So I would have to extend the WAR by this filter. BUT from the link to the documentation it seems to me that EVERY request has to be redirected to the index.html BUT form code it seems that some extensions are not redirected - that seems to be absolutely correct for me as a *png should not be redirect to index.html ... just confuses me.
          – PaulEdison
          Nov 6 at 3:29


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53088876%2fhow-to-configure-weblogic-application-sever-for-angular-application%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Full-time equivalent

          Bicuculline

          さくらももこ