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>
- I first login so I can go trough the first filter.
- 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
add a comment |
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>
- I first login so I can go trough the first filter.
- 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
please add the code of yourAHSFilters.connexionFilter
– Roshana Pitigala
Nov 18 at 11:48
@RoshanaPitigala Done. Many thanks in advance
– JSmith
Nov 18 at 19:43
add a comment |
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>
- I first login so I can go trough the first filter.
- 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
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>
- I first login so I can go trough the first filter.
- 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
html jsp google-app-engine java-ee
edited Nov 19 at 1:58
asked Nov 18 at 2:39
JSmith
1,33311024
1,33311024
please add the code of yourAHSFilters.connexionFilter
– Roshana Pitigala
Nov 18 at 11:48
@RoshanaPitigala Done. Many thanks in advance
– JSmith
Nov 18 at 19:43
add a comment |
please add the code of yourAHSFilters.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
add a comment |
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
thank you it worked
– JSmith
Nov 19 at 11:30
1
@JSmith My pleasure man !
– Avijit Barua
Nov 19 at 11:30
add a comment |
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
thank you it worked
– JSmith
Nov 19 at 11:30
1
@JSmith My pleasure man !
– Avijit Barua
Nov 19 at 11:30
add a comment |
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
thank you it worked
– JSmith
Nov 19 at 11:30
1
@JSmith My pleasure man !
– Avijit Barua
Nov 19 at 11:30
add a comment |
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
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
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
add a comment |
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
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%2f53357409%2fgetrequestdispatcher-dispatching-jsp-but-not-html%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
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