How to configure Weblogic application Sever for Angular application
up vote
4
down vote
favorite
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
add a comment |
up vote
4
down vote
favorite
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
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
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
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
angular weblogic config
edited Nov 10 at 15:31
Al Fahad
735620
735620
asked Oct 31 at 17:17
PaulEdison
8410
8410
add a comment |
add a comment |
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
}
}
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
add a comment |
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
}
}
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
add a comment |
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
}
}
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
add a comment |
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
}
}
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
}
}
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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