Why is a JSP website showing the wrong path or a 404 error?

If your JSP website is showing the wrong path or returning a 404 error, the issue is usually related to how the application is deployed, how Tomcat resolves the context path, or how Apache/Plesk routes requests to your Java application. In most cases, the file is not actually missing. Instead, the browser is requesting the application under a different URL than the one Tomcat expects, or the app server is not running the version of the app you think it is.

This article explains the most common causes of wrong-path and 404 problems for JSP hosting, and shows how to check them in a Plesk-based hosting environment with My App Server, Apache Tomcat, and a private JVM.

What this error usually means

A “wrong path” or 404 error for a JSP site typically means one of these things:

  • The application is deployed under a different context path than the URL you are using.
  • The Tomcat service is stopped, restarting, or running the wrong application version.
  • Apache is forwarding requests incorrectly, or the rewrite rules are not matching the expected path.
  • The JSP file exists, but the application expects a different folder structure or route.
  • The app was uploaded in the wrong directory, such as inside a nested folder instead of the web root.
  • A .war package was deployed successfully, but the generated application name does not match the browser URL.

For JSP hosting, a 404 error is often a routing or deployment issue rather than a code error. That is especially true when the site worked before, but starts failing after a redeploy, a Java version change, a Tomcat restart, or a domain mapping update in Plesk.

Common reasons a JSP site shows the wrong path

1. The context path does not match the URL

Tomcat serves each application under a context path. For example, if your app is deployed as myapp.war, the site may be available at /myapp, not at the domain root.

Typical examples:

  • example.com/myapp works, but example.com returns 404.
  • example.com/app works, but your bookmark points to example.com/site.
  • After upload, the app is accessible only under a renamed folder or WAR name.

In Tomcat, the deployed application name often becomes the path. If you want the site to load at the domain root, the app must usually be deployed accordingly, or a mapping/redirect must be configured.

2. The app was deployed to the wrong folder

A JSP application must be deployed in the correct web application structure. If files are placed in the wrong directory, Tomcat may not treat them as part of the application.

Check for common mistakes such as:

  • Uploading JSP files into a folder that is not the document root.
  • Putting the application inside an extra nested folder.
  • Deploying only a single JSP file when the app expects a full Java webapp structure.
  • Mixing static site files and Tomcat application files in the wrong location.

3. Apache and Tomcat are not aligned

In a Plesk hosting environment, Apache often serves the domain and passes Java application requests to Tomcat through the hosting configuration. If the Apache mapping is incorrect, the browser may reach the wrong handler, or a path that Tomcat does not know about.

This can happen after:

  • changing the domain document root
  • reinstalling the Java app server
  • switching Java/Tomcat versions in My App Server
  • adding or removing a custom context
  • editing rewrite rules manually

4. The application name changed after redeploy

When a WAR file is uploaded, Tomcat can rename the application based on the file name. If you upload shop.war one day and shop-v2.war later, the URL may change from /shop to /shop-v2.

This is one of the most common reasons users see a 404 even though deployment succeeded. The browser is still pointing to the previous application path.

5. The welcome file or main route is missing

If the application opens at the folder path but not at the root, Tomcat may not find a default page such as index.jsp or index.html. In that case, the app may work when you request a direct JSP path, but fail when you visit the base URL.

Example:

  • /myapp/home.jsp works
  • /myapp/ returns 404

This usually means the welcome file configuration is missing or the app expects a different landing page.

How to troubleshoot the issue in Plesk and My App Server

Step 1: Confirm the exact URL you are using

Start by checking the full address in the browser. Compare it with the deployed application name in Plesk or the WAR filename you uploaded.

Verify whether you are visiting:

  • the domain root, such as https://example.com/
  • a subpath, such as https://example.com/app/
  • a JSP file directly, such as https://example.com/app/test.jsp

If the app was deployed under a context path, the root domain may not be the correct URL.

Step 2: Check the My App Server status

In the control panel, open the My App Server section and confirm that the service is running. A stopped Java service can return 404 or routing errors if Apache is still trying to forward requests to it.

Look for:

  • service status: running
  • correct Java version selected
  • Tomcat instance assigned to the subscription or domain
  • no deployment errors in the service log

If the service was recently restarted, wait a moment and then test again. Some applications need a short time to redeploy.

Step 3: Verify the deployed application name

Check the application name shown in Plesk or in the Tomcat deployment list. This is often the path segment you must use in the browser.

For example:

  • WAR file: demo.war
  • Deployed app path: /demo
  • Correct URL: https://example.com/demo/

If you want a different URL, rename the WAR or configure the context path in the app server settings, if supported in your setup.

Step 4: Make sure the app is deployed in the correct web application structure

For JSP hosting, the application should follow the expected Tomcat webapp layout. A common structure includes:

  • JSP pages
  • WEB-INF folder
  • web.xml if your app uses one
  • compiled classes and libraries where required

If the application is incomplete, Tomcat may not map routes properly. You may see 404 on a specific JSP even though the file exists on disk.

Step 5: Test a direct JSP path

If the base URL shows 404, try opening a specific JSP file that you know exists. This helps determine whether the problem is the welcome page or the whole application path.

Examples:

  • /app/index.jsp
  • /app/login.jsp
  • /app/test.jsp

If a direct file works but the root path does not, the issue is likely the default page configuration rather than the deployment itself.

Step 6: Check for rewrite rules or redirects

Apache rewrite rules can accidentally send requests to the wrong folder or a non-existent path. This can happen if you have custom .htaccess rules, domain redirects, or URL rewriting meant for a static site but applied to a Java app.

Review any rules that:

  • force the site to a specific folder
  • redirect / to another app path
  • rewrite all requests to an index file that is not used by Tomcat
  • remove or add trailing slashes incorrectly

For JSP applications, it is often best to keep rewrite rules simple unless the application specifically requires them.

Step 7: Clear browser cache and test in a private window

Cached redirects or old paths can make it look like the server is broken when the problem is actually in the browser cache. Test the site in an incognito or private window, or use another browser.

This is especially useful after:

  • changing the deployment name
  • moving the app to a different context path
  • updating DNS or the domain mapping
  • restarting Tomcat

Step 8: Review the service and application logs

If the issue continues, check the logs from the hosting control panel. In a My App Server setup, logs can reveal whether Tomcat failed to deploy the app, whether the JVM started correctly, or whether a path mapping failed.

Look for messages about:

  • deployment failure
  • context path conflicts
  • missing classes or libraries
  • port or connector problems
  • access to a path that does not exist

If the logs show that the application did not deploy cleanly, redeploy it and make sure the package is complete.

How to fix the problem

Match the URL to the deployed context path

If the app is deployed as /myapp, use that exact path in the browser. If you need the site to open from the domain root, adjust the deployment name or configure the root application mapping in your environment.

Rename the WAR file carefully

If you deploy by uploading a WAR file, its filename may define the public path. Use a stable name and avoid frequent renaming unless you also update bookmarks, internal links, and redirects.

Correct the web root and file placement

Ensure that the application files are placed where Tomcat expects them. A JSP file alone is not always enough. If the app has Java classes, libraries, and configuration files, they must be uploaded as part of a valid web application structure.

Fix default page handling

If the app loads only when you specify a full file name, add or correct the welcome page configuration. Many JSP applications use index.jsp as the landing page, but some use a controller servlet or another route.

Remove conflicting redirects

If Apache or .htaccess rules conflict with the Java app, simplify them. Keep only the necessary rules and avoid forcing paths that do not exist in Tomcat.

Restart the app server after changes

After changing the Java version, Tomcat configuration, deployment name, or routing rules, restart the My App Server service from the control panel. This ensures the new configuration is loaded correctly.

Special notes for JSP hosting with My App Server

My App Server is designed for practical JSP hosting, Tomcat hosting, servlet hosting, and private JVM use within a shared hosting account. That makes it suitable for small and medium Java applications that need a manageable deployment workflow through Plesk.

For path and 404 issues, the most useful features are:

  • control of the app server from the panel
  • choice of Java version
  • separate Tomcat instance for your account
  • easy deployment of WAR-based applications
  • simple service restart when troubleshooting

If you uploaded a custom application server or a manually configured Tomcat instance, path handling may depend on how the context is defined. In that case, check the application name, virtual host mapping, and any custom configuration you added during setup.

Examples of typical scenarios

Scenario 1: The domain root shows 404, but /app works

This usually means the application is deployed under /app, not the root domain. The fix is to use the correct URL or redeploy the application under the expected context.

Scenario 2: The site worked yesterday, now it shows the wrong path

This often happens after a redeploy with a different WAR name, a Tomcat restart, or a change to Apache routing. Check whether the deployed application path changed and whether the browser is still using an old URL.

Scenario 3: A JSP file exists on disk, but the browser gets 404

This usually indicates that the file is outside the deployed web root, the application did not deploy fully, or the request is being sent to a different context path than expected.

Scenario 4: The app opens, but one JSP page fails

This suggests a route or file-specific issue. Check the file name, case sensitivity, folder structure, and any application logic that forwards to the page.

Frequently asked questions

Why does my JSP site work on one path but not another?

Because Tomcat serves the application under a specific context path. If the URL does not match that path, the server returns 404. Check the deployed app name in Plesk or My App Server.

Can a wrong WAR filename cause a 404?

Yes. The WAR filename often becomes the public path. If you rename the file, the URL may change too.

Why do I get 404 after restarting Tomcat?

The app may not have redeployed cleanly, the service may not be fully running, or the application path may have changed. Check the deployment status and logs.

Do I need a default index.jsp file?

Not always, but if you want the application to open from the base path, a welcome file such as index.jsp is often needed unless the app uses a different landing route.

Can Apache rewrite rules break a JSP application?

Yes. If rewrite rules send requests to the wrong folder or to a non-existent file, the app may appear broken even though Tomcat is running normally.

What should I check first if the path is wrong?

First check the exact URL, then the deployed app name, then the My App Server status. These three checks solve many JSP 404 issues.

Recommended checklist before contacting support

  • Confirm the full browser URL.
  • Compare it with the deployed application name.
  • Verify that My App Server is running.
  • Test the site in a private browser window.
  • Try a direct JSP file path.
  • Review Apache rewrite rules or redirects.
  • Check deployment and service logs for errors.
  • Restart the Java service after any configuration change.

Conclusion

A JSP website showing the wrong path or a 404 error is usually caused by a mismatch between the URL, the Tomcat context path, or the deployment structure. In a Plesk-based hosting environment with My App Server, the quickest fix is usually to verify the deployed app name, confirm that the Java service is running, and make sure Apache and Tomcat are pointing to the same application path.

If the application still fails after checking the URL, deployment name, and logs, redeploy the app with a consistent WAR filename and test the site again. For persistent issues, the problem is often in the routing or application structure rather than the JSP code itself.

  • 0 Users Found This Useful
Was this answer helpful?