Custom error pages not showing up? - html

I have Tomcat installed and whenever the user hits a 404 pages or 500 page it shows the Tomcats error page. But, then I have created a custom 404 and 500 error pages and put it inside my web.xml file. But, I can't see my custom error page displayed. Please check my code and see what is going on. Thank you for the help.
Here is my code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>report.url</param-name>
<param-value>https://MY_URL_LINK.net/jasperserver-pro/rest_v5/reports/organizations/organization_2</param-value>
</context-param>
<context-param>
<param-name>report.path.mode</param-name>
<param-value>report.path</param-value>
</context-param>
<context-param>
<param-name>report.path.test</param-name>
<param-value>C:\\Program Files\\glassfish-4.1\\glassfish\\domains\\domain1\\applications\\PayApp-5.0-SNAPSHOT\\reports\\</param-value>
</context-param>
<context-param>
<param-name>report.path</param-name>
<param-value>/usr/share/glassfish3/glassfish/domains/domain1/applications/PayApp/reports/</param-value>
</context-param>
<!-- THIS IS MY ERROR PAGES SHOWN BELOW -->
<error-page>
<!-- Missing resource -->
<error-code>404</error-code>
<location>/Error404.xhtml</location>
</error-page>
<error-page>
<!-- Uncaught exception -->
<error-code>500</error-code>
<location>/Error500.xhtml</location>
</error-page>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
25
</session-timeout>
</session-config>
<filter>
<filter-name>LoginFilter</filter-name>
<filter-class>org.pay.filters.LoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LoginFilter</filter-name>
<url-pattern>/secure/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<resource-ref>
<res-ref-name>/oracleInstance</res-ref-name>
<res-type>javax.sql.ConnectionPoolDataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jdbc/w2Instance</res-ref-name>
<res-type>javax.sql.ConnectionPoolDataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>

Related

How to make a SwipeRefreshLayout doesn't trigger when I am using a Google map?

I am working in Android Studio, I have a SwipeRefreshLayout and inside this a WebvIew that loads a Google map, when I try to move around the map and I slide from above the WebView is updated making it impossible to use the map correctly, is there any way to solve this ?
The layout code
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/app_bar_main">
<WebView
android:id="#+id/mainWV"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp" >
</WebView>

Using Custom view.phtml into Magento using local.xml

I've been looking and I can't find the exact answer to my question. I've created a custom view.phtml file on my site and stored it in my "customchanges" folder located at /app/design/frontend/argento/default/template/customchanges/catalog/product/view.phtml
I've also created a local.xml file which I store in /app/design/frontend/argento/default/layout/local.xml
My code in my local.xml file is:
<?xml version="1.0"?>
<layout>
<default>
<reference name="product.info">
<action method="setTemplate"><template>customchanges/catalog/product/view.phtml</template></action>
</reference>
</default>
</layout>
But when I refresh the page (and use hints) I still get the default page. Please could someone help?
Thanks
Chris
I managed to fix this, if it's helpful here's the solution:
<layout version="0.1.0">
<catalog_product_view>
<reference name="product.info">
<action method="setTemplate">
<template>customchanges/catalog/product/view.phtml</template>
</action>
</reference>
</catalog_product_view>
</layout>

Unable to download file using CORS

I want to make a Cross-Domain request to download a file from my java web application. I am using the CORS filter and have included the configuration in my deployment descriptor(web.xml):
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
I have the cross domain URL in the href attribute:
download
Now when I click the link, the whole page is redirected and the file is downloaded. Can I know what how can I achive this.
Thanks
I faced a similar problem sometime ago. You will not be able to download the file using a GET request using href attribute as u mentioned in the question.
Instead you can submit a form embedded in an iframe as suggested here and submit the form with your file id as a hidden element and it should trigger the download. So your anchor tag shall be:
download
Now pass your fileId as parameter to the onclick JS function and define it like this:
function downloadFile(fileId) {
let $iframe, iframeDoc, iframeHtml;
if(($iframe = $('#download_frame')).length === 0) {
$iframe = $('<iframe id="download_frame" +
' style="display: none;" src="about:blank"></iframe>'
).appendTo('body');
}
iframeDoc= $iframe[0].contentWindow;
if (iframeDoc.document) {
iframeDoc= iframeDoc.document;
}
iframeHtml= '<html><head></head><body><form method="POST" action="http:localhost:8080/MyProject/downloadAction.action"><input type="hidden" name="fileId" value="'+fileId+'"></form></body></html>';
iframeDoc.open();
iframeDoc.write(iframeHtml);
$(iframeDoc).find('form').submit();
}
You can follow similar approach for single or multiple files.
Also to add you can include this in ur web.xml in the filter configuration:
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,X-Test-Header,Cache-Control
</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials
</param-value>
</init-param>

No mapping found for resource files in DispatcherServlet

I've got the following problem on every single page I am trying to access
WARNING [http-nio-8080-exec-7]
org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping
found for HTTP request with URI
[/cart/%3Cc:url%20value='/resources/css/bootstrap.css'%20/%3E] in
DispatcherServlet with name 'springmvc-dispatcher
There are warnings, but those resources are visible (both css and scripts are working, still gives errors), and I have nothing underlined in jsp files.
<link href="<c:url value='/resources/css/bootstrap.css' />" rel="stylesheet"/>
<script src="<c:url value="/resources/js/controllers.js"/>"></script>
I have above paths to css and js in every jsp file.
Project-Structure
And my filter mapping:
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
You haven't used DispatcherServlet in your mapping. Just try this.
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>

Faces Servlet threw exception java.lang.StackOverflowError

Ok, I've run across my first StackOverflowError since joining this site, I figured this is a must post :-). My environment is Seam 2.0.1.GA, JBoss 4.2.2.GA and I'm using JSF. I am in the process of converting from a facelets view to JSP to take advantage of some existing JSP tags used on our existing site. I changed the faces-config.xml and the web.xml configuration files and started to receive the following error when trying to render a jsp page. Anyone have any thoughts?
2008-09-17 09:45:17,537 DEBUG
[org.jboss.seam.contexts.FacesLifecycle]
Begin JSF request for /form_home.jsp
2008-09-17 09:45:17,587 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/].[Faces
Servlet]] Servlet.service() for
servlet Faces Servlet threw exception
java.lang.StackOverflowError
at org.apache.catalina.core.ApplicationHttpRequest.getAttribute(ApplicationHttpRequest.java:210)
at org.apache.catalina.core.ApplicationHttpRequest.getAttribute(ApplicationHttpRequest.java:222)
at org.apache.catalina.core.ApplicationHttpRequest.getAttribute(ApplicationHttpRequest.java:222)
at org.apache.catalina.core.ApplicationHttpRequest.getAttribute(ApplicationHttpRequest.java:222)
...
My faces-config.xml file is now empty with no FaceletsViewHandler:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
</faces-config>
And my Web.xml file:
<?xml version="1.0"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Ajax4jsf -->
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<!-- Seam -->
<listener>
<listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
</listener>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
<!-- Seam end -->
<!-- JSF -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
I was able to figure out this problem. Apparently you can not configure web.xml to have the same param-value of .jsp for Javax.faces.DEFAULT_SUFFIX as the Faces Servlet url-pattern (*.jsp). If you change your url-pattern to .jspx or to /whateverdirnameyouwant/ the application starts up with no stack overflow errors. (note: the key is that DEFAULT_SUFFIX and Faces Servlet url-pattern cannot be the same regardless of what they are.) Hope this helps anyone else that experiences this specific problem.
Stack overflows in java are almost always caused by infinite recursion / method calls. In your case given the stack trace, it appears 'getAttribute()' is being called repeatedly until crash. While I'm not intimately familiar with the particular environments you are using, I would suggest checking your .jsp code for any of this type of behaviour (for example two methods that call each other)
So, I had a similar error. For me, it was that I had a JSF project and I was messing around with the file extensions. To start with, I had all my web files with extension .jsp. This was working, but then I wanted them to be all .jsf, then after that I went all in on using .xhtml. In the process, my web.xml file changed to accomodate xhtml and jsf. Changing the web.xml file was fine. What got me the StackOverflowError was that I had index.xhtml with a ui.include tag pointing to header.jsf. So I had a xhtml file pointing to a jsf file. I had thought that web.xml would be able to handle this, but it did not, I got the StackOverflowError. So, to fix this, now all my JSF files have extension .xhtml, and nested ui:include tags point to .xhtml files.
On the flip side, though, the browser url can handle the index.jsp, index.jsf, index.xhtml just fine. So the web.xml (with servlet mappings for jsp, jsf and xhtml) handles the browser url just fine, but not for what my problem above highlighted.