0

I am using Tomcat 6 on an Apache server and have an app in webapps called support that is working correctly. There are two urls that are used in calling pages called register and activate. They are both accessed by www.oururl.com/support/activate and the same scenario for register. We would like to have the register to go to a static page at www.oururl.com/staticphppage.php. I have tried all sorts of options for the past 4 days and can not get this to work. I am rather new at java so this has been a huge learning curve. Any help would greatly be appreciated.

I have tried to map another servlet in web.xml but it never comes thru to work and always gives a 404 error.

I am sure I am way off on this even after looking at lots of example code and trying to morph it to what we need. All we really want is to keep everything in place as far as url access on the web and redirect the support/register to a static page. I also tried to do this right in Tomcat with by editing the server file with the redirect and could not. Thanks for any and all help it is very much appreciated.

This is my current web.xml with the new servlet added called page

    <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xmlns="http://java.sun.com/xml/ns/javaee" 
         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
         id="WebApp_ID" version="2.5">

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>
                Software Registration System
            </web-resource-name>             
            <url-pattern>/activate</url-pattern>            
            <url-pattern>/register</url-pattern>
            <url-pattern>/admin</url-pattern>
            <url-pattern>/admin/</url-pattern>
            <url-pattern>/admin/*</url-pattern>         
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>  

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <!-- Reads request input using UTF-8 encoding -->
    <filter>
        <filter-name>characterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>

    <filter>
        <filter-name>osivFilter</filter-name>
        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>characterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>       
    </filter-mapping>

    <filter-mapping>
        <filter-name>osivFilter</filter-name>
        <url-pattern>/*</url-pattern>       
    </filter-mapping>   

    <listener>
        <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
    </listener>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>    
    </listener> 

    <context-param>
        <param-name>contextConfigLocation</param-name> 
        <param-value>
            classpath:/application-context.xml          
            classpath:/repository-context.xml       
            classpath:/security-context.xml
        </param-value> 
    </context-param>

    <servlet>
        <servlet-name>Software Support System</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/support-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <session-config>  
        <session-timeout>8</session-timeout>  
    </session-config>  

    <servlet-mapping>

        <servlet-name>Software Support System</servlet-name>
        <url-pattern>/activate</url-pattern>
    </servlet-mapping>

    <servlet>
    <servlet-name>page</servlet-name>
    <jsp-file>/staticphppage.php</jsp-file>
</servlet>
<servlet-mapping>
    <servlet-name>page</servlet-name>
    <url-pattern>/register</url-pattern>
</servlet-mapping>


</web-app>
TimM
  • 1
  • Are you serving PHP pages from tomcat? And can you clarify on "they are both accessed by (same URL)" - It sounds like two servlets would be available under the same URL? How would you determine which one to serve, if not through the URL? I'd say that this is not possible, or at least a very unusual configuration. Especially when you say you're at the beginning of your learning curve. – Olaf Kock Jun 21 '19 at 07:55
  • I have the php page at the root of the domain and it works just fine. One url is accessed by https://www.dpctrack2.com/support/register/ and the other is at https://www.dpctrack2.com/support/activate. The name of the app in webapps is support. The activate version is fine, we would just like the register to go to the root of the domain php page. I am able to map the servlet in the web.xml. I just can't add the mapping for the register link to go to the root domain, not sure of the code. Yes we want to serve each url respectively. Thanks for your help. – TimM Jun 21 '19 at 11:24

0 Answers0