getRequestDispatcher dispatching jsp but not html











up vote
-1
down vote

favorite












I am running google app engine and using JAVAEE.



I have a two filters but only one is configured with restrictions.



WEB.XML



<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<filter>
<filter-name>connexionFilter</filter-name>
<filter-class>AHSFilters.connexionFilter</filter-class>
</filter>
<filter>
<filter-name>restrictFilter</filter-name>
<filter-class>AHSFilters.restrictFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>connexionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>restrictFilter</filter-name>
<url-pattern>/client</url-pattern>
<url-pattern>/admin</url-pattern>
</filter-mapping>
</web-app>



  1. I first login so I can go trough the first filter.

  2. I change my url to localhost:8080/client


my connexion filter is as so:



    package AHSFilters;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class connexionFilter implements Filter {

@Override
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub

}

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
HttpSession session = req.getSession();

if(session.getAttribute("sessionUser") != null)
chain.doFilter(req, resp);
if (req.getHeader("X-Requested-With") != null)
chain.doFilter(req, resp);
else
req.getServletContext().getRequestDispatcher("/").forward(request, response);
// TODO Auto-generated method stub

}

@Override
public void destroy() {
// TODO Auto-generated method stub

}

}


my servlet is as so:



package AHSServlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebServlet(
name = "ClientServ",
urlPatterns = {"/client"}
)
public class ClientServ extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.getWriter().flush();
this.getServletContext().getRequestDispatcher("/restrict/client/test.jsp").forward(request, response);;
}
}


when my file is setted to test.jsp I go to the correct page, but when I rename it to test.html and of course change the path in getRequestDispatcher I get redirected to my login page (/ route).



So I have to files /restrict/client/test.jsp i get the correct response
and /restrict/client/test.html I go back to the signin page.



I've tried putting a simple hello in test.html also tried with valid html page with the same result. Is there any settings I'm missing in order to allow html?



Where could it come from? Any help is greatly appreciated.










share|improve this question
























  • please add the code of your AHSFilters.connexionFilter
    – Roshana Pitigala
    Nov 18 at 11:48










  • @RoshanaPitigala Done. Many thanks in advance
    – JSmith
    Nov 18 at 19:43















up vote
-1
down vote

favorite












I am running google app engine and using JAVAEE.



I have a two filters but only one is configured with restrictions.



WEB.XML



<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<filter>
<filter-name>connexionFilter</filter-name>
<filter-class>AHSFilters.connexionFilter</filter-class>
</filter>
<filter>
<filter-name>restrictFilter</filter-name>
<filter-class>AHSFilters.restrictFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>connexionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>restrictFilter</filter-name>
<url-pattern>/client</url-pattern>
<url-pattern>/admin</url-pattern>
</filter-mapping>
</web-app>



  1. I first login so I can go trough the first filter.

  2. I change my url to localhost:8080/client


my connexion filter is as so:



    package AHSFilters;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class connexionFilter implements Filter {

@Override
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub

}

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
HttpSession session = req.getSession();

if(session.getAttribute("sessionUser") != null)
chain.doFilter(req, resp);
if (req.getHeader("X-Requested-With") != null)
chain.doFilter(req, resp);
else
req.getServletContext().getRequestDispatcher("/").forward(request, response);
// TODO Auto-generated method stub

}

@Override
public void destroy() {
// TODO Auto-generated method stub

}

}


my servlet is as so:



package AHSServlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebServlet(
name = "ClientServ",
urlPatterns = {"/client"}
)
public class ClientServ extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.getWriter().flush();
this.getServletContext().getRequestDispatcher("/restrict/client/test.jsp").forward(request, response);;
}
}


when my file is setted to test.jsp I go to the correct page, but when I rename it to test.html and of course change the path in getRequestDispatcher I get redirected to my login page (/ route).



So I have to files /restrict/client/test.jsp i get the correct response
and /restrict/client/test.html I go back to the signin page.



I've tried putting a simple hello in test.html also tried with valid html page with the same result. Is there any settings I'm missing in order to allow html?



Where could it come from? Any help is greatly appreciated.










share|improve this question
























  • please add the code of your AHSFilters.connexionFilter
    – Roshana Pitigala
    Nov 18 at 11:48










  • @RoshanaPitigala Done. Many thanks in advance
    – JSmith
    Nov 18 at 19:43













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I am running google app engine and using JAVAEE.



I have a two filters but only one is configured with restrictions.



WEB.XML



<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<filter>
<filter-name>connexionFilter</filter-name>
<filter-class>AHSFilters.connexionFilter</filter-class>
</filter>
<filter>
<filter-name>restrictFilter</filter-name>
<filter-class>AHSFilters.restrictFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>connexionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>restrictFilter</filter-name>
<url-pattern>/client</url-pattern>
<url-pattern>/admin</url-pattern>
</filter-mapping>
</web-app>



  1. I first login so I can go trough the first filter.

  2. I change my url to localhost:8080/client


my connexion filter is as so:



    package AHSFilters;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class connexionFilter implements Filter {

@Override
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub

}

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
HttpSession session = req.getSession();

if(session.getAttribute("sessionUser") != null)
chain.doFilter(req, resp);
if (req.getHeader("X-Requested-With") != null)
chain.doFilter(req, resp);
else
req.getServletContext().getRequestDispatcher("/").forward(request, response);
// TODO Auto-generated method stub

}

@Override
public void destroy() {
// TODO Auto-generated method stub

}

}


my servlet is as so:



package AHSServlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebServlet(
name = "ClientServ",
urlPatterns = {"/client"}
)
public class ClientServ extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.getWriter().flush();
this.getServletContext().getRequestDispatcher("/restrict/client/test.jsp").forward(request, response);;
}
}


when my file is setted to test.jsp I go to the correct page, but when I rename it to test.html and of course change the path in getRequestDispatcher I get redirected to my login page (/ route).



So I have to files /restrict/client/test.jsp i get the correct response
and /restrict/client/test.html I go back to the signin page.



I've tried putting a simple hello in test.html also tried with valid html page with the same result. Is there any settings I'm missing in order to allow html?



Where could it come from? Any help is greatly appreciated.










share|improve this question















I am running google app engine and using JAVAEE.



I have a two filters but only one is configured with restrictions.



WEB.XML



<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<filter>
<filter-name>connexionFilter</filter-name>
<filter-class>AHSFilters.connexionFilter</filter-class>
</filter>
<filter>
<filter-name>restrictFilter</filter-name>
<filter-class>AHSFilters.restrictFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>connexionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>restrictFilter</filter-name>
<url-pattern>/client</url-pattern>
<url-pattern>/admin</url-pattern>
</filter-mapping>
</web-app>



  1. I first login so I can go trough the first filter.

  2. I change my url to localhost:8080/client


my connexion filter is as so:



    package AHSFilters;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class connexionFilter implements Filter {

@Override
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub

}

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
HttpSession session = req.getSession();

if(session.getAttribute("sessionUser") != null)
chain.doFilter(req, resp);
if (req.getHeader("X-Requested-With") != null)
chain.doFilter(req, resp);
else
req.getServletContext().getRequestDispatcher("/").forward(request, response);
// TODO Auto-generated method stub

}

@Override
public void destroy() {
// TODO Auto-generated method stub

}

}


my servlet is as so:



package AHSServlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebServlet(
name = "ClientServ",
urlPatterns = {"/client"}
)
public class ClientServ extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.getWriter().flush();
this.getServletContext().getRequestDispatcher("/restrict/client/test.jsp").forward(request, response);;
}
}


when my file is setted to test.jsp I go to the correct page, but when I rename it to test.html and of course change the path in getRequestDispatcher I get redirected to my login page (/ route).



So I have to files /restrict/client/test.jsp i get the correct response
and /restrict/client/test.html I go back to the signin page.



I've tried putting a simple hello in test.html also tried with valid html page with the same result. Is there any settings I'm missing in order to allow html?



Where could it come from? Any help is greatly appreciated.







html jsp google-app-engine java-ee






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 1:58

























asked Nov 18 at 2:39









JSmith

1,33311024




1,33311024












  • please add the code of your AHSFilters.connexionFilter
    – Roshana Pitigala
    Nov 18 at 11:48










  • @RoshanaPitigala Done. Many thanks in advance
    – JSmith
    Nov 18 at 19:43


















  • please add the code of your AHSFilters.connexionFilter
    – Roshana Pitigala
    Nov 18 at 11:48










  • @RoshanaPitigala Done. Many thanks in advance
    – JSmith
    Nov 18 at 19:43
















please add the code of your AHSFilters.connexionFilter
– Roshana Pitigala
Nov 18 at 11:48




please add the code of your AHSFilters.connexionFilter
– Roshana Pitigala
Nov 18 at 11:48












@RoshanaPitigala Done. Many thanks in advance
– JSmith
Nov 18 at 19:43




@RoshanaPitigala Done. Many thanks in advance
– JSmith
Nov 18 at 19:43












1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










I think in order to do so you need little configuration. In web.xml write a configuration code



<jsp-config>
<jsp-property-group>
<url-pattern>*.html</url-pattern>
</jsp-property-group>
</jsp-config>


To understand better you can check



Can you render a file without a .jsp extension as a JSP?



Running .jsp as .html file






share|improve this answer





















  • thank you it worked
    – JSmith
    Nov 19 at 11:30






  • 1




    @JSmith My pleasure man !
    – Avijit Barua
    Nov 19 at 11:30











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%2f53357409%2fgetrequestdispatcher-dispatching-jsp-but-not-html%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
2
down vote



accepted










I think in order to do so you need little configuration. In web.xml write a configuration code



<jsp-config>
<jsp-property-group>
<url-pattern>*.html</url-pattern>
</jsp-property-group>
</jsp-config>


To understand better you can check



Can you render a file without a .jsp extension as a JSP?



Running .jsp as .html file






share|improve this answer





















  • thank you it worked
    – JSmith
    Nov 19 at 11:30






  • 1




    @JSmith My pleasure man !
    – Avijit Barua
    Nov 19 at 11:30















up vote
2
down vote



accepted










I think in order to do so you need little configuration. In web.xml write a configuration code



<jsp-config>
<jsp-property-group>
<url-pattern>*.html</url-pattern>
</jsp-property-group>
</jsp-config>


To understand better you can check



Can you render a file without a .jsp extension as a JSP?



Running .jsp as .html file






share|improve this answer





















  • thank you it worked
    – JSmith
    Nov 19 at 11:30






  • 1




    @JSmith My pleasure man !
    – Avijit Barua
    Nov 19 at 11:30













up vote
2
down vote



accepted







up vote
2
down vote



accepted






I think in order to do so you need little configuration. In web.xml write a configuration code



<jsp-config>
<jsp-property-group>
<url-pattern>*.html</url-pattern>
</jsp-property-group>
</jsp-config>


To understand better you can check



Can you render a file without a .jsp extension as a JSP?



Running .jsp as .html file






share|improve this answer












I think in order to do so you need little configuration. In web.xml write a configuration code



<jsp-config>
<jsp-property-group>
<url-pattern>*.html</url-pattern>
</jsp-property-group>
</jsp-config>


To understand better you can check



Can you render a file without a .jsp extension as a JSP?



Running .jsp as .html file







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 at 5:58









Avijit Barua

1,0591215




1,0591215












  • thank you it worked
    – JSmith
    Nov 19 at 11:30






  • 1




    @JSmith My pleasure man !
    – Avijit Barua
    Nov 19 at 11:30


















  • thank you it worked
    – JSmith
    Nov 19 at 11:30






  • 1




    @JSmith My pleasure man !
    – Avijit Barua
    Nov 19 at 11:30
















thank you it worked
– JSmith
Nov 19 at 11:30




thank you it worked
– JSmith
Nov 19 at 11:30




1




1




@JSmith My pleasure man !
– Avijit Barua
Nov 19 at 11:30




@JSmith My pleasure man !
– Avijit Barua
Nov 19 at 11:30


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357409%2fgetrequestdispatcher-dispatching-jsp-but-not-html%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

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]