Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8550127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:52:48+00:00 2026-06-11T13:52:48+00:00

I have a route() that fires when I go to http://localhost:8080/ and it’s working,

  • 0

I have a route() that fires when I go to http://localhost:8080/ and it’s working, but it is blocking my resources from loading. e.g http://localhost:8080/mobile/css/styles.css returns 404

I used <url-pattern>/</url-pattern> in my web.xml and @Path("/") in my code. Any ideas how I can serve my static content while dynamically creating the index.html?

Thanks!

Edit – I want to avoid doing a redirect and keep my URL clean. If there is another framework that can do this better I’d be willing to try it. I’m not attached to JAX-RS.

package com.project.router;
@Path("/")
@Produces({MediaType.TEXT_HTML})
public class Router {

    final String FULL_WEB = "";
    final String MOBILE_WEB = "C:\\workspace\\project\\web\\mobile\\index.html";

    @GET
    @Produces({MediaType.TEXT_HTML})
    public Response route(@HeaderParam("user-agent") String userAgent, @HeaderParam("accept") String accept) throws FileNotFoundException {
        UAgentInfo uAgentInfo = new UAgentInfo(userAgent,accept);
        boolean tierIphone = uAgentInfo.detectTierIphone();
        File file = null;
        if (tierIphone) {
            file = new File(MOBILE_WEB);
        } else {
            file = new File(FULL_WEB);
        }

        FileInputStream fileInputStream = new FileInputStream(file);
        return Response.ok().entity(fileInputStream).build();
    }
}

web.xml

<servlet>
    <servlet-name>router</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.project.router</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
        <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>router</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:52:49+00:00Added an answer on June 11, 2026 at 1:52 pm

    You should give a diffent url-pattern for your router servlet else all requests are going to reach your Router class. The static content will automatically work.

    Maybe

    <servlet-mapping>     
        <servlet-name>router</servlet-name>     
        <url-pattern>/router</url-pattern>
    </servlet-mapping> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a route that is suppose to match something like this localhost:3000/site/admin and
I have a custom routing application that takes information for a route from google
I have a Pyramid app that I've been developing and viewing locally through http://localhost:6543
I want to have a route that looks something like: www.abc.com/companyName/Controller/Action/Id However, all the
I have a bus route that travels on a route (sequence of places) in
I have an apache servicemix (camel 2.9) route which calls a bean, that in
I have a hairy set of routes that I'm upgrading from Rails 2 to
I made a custom handler that derives from MvcHandler. I have my routes using
I have an asp.net mvc app with a route that allows users to request
Essentially, my route is working perfectly, Passenger seems to be loading - all is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.