Question

I wrote a very simple jboss 7 servlet app using eclipse/kepler with the jboss plugins from redhat. I deployed the war file to cloudbees. the simple.jsp page is using:

... this works on my local runtime deployment -- but, its not working in the context of the cloud (no real surprise there). So if my app gets deployed as: http://simplepaaswebtest.metro-pojo.cloudbees.net/simple.jsp

what context do i use for the post back?

Was it helpful?

Solution

Looking at the HTML source of your form, I can see that the action attribute of your form is /SimplePaasWebTest/SimpleServlet. /SimplePaasWebTest looks like an application context path that you configured locally for your app, but when running on CloudBees, the app is assigned an empty context path, which changes the path you need to submit to. If you change your form submission to /SimpleServlet, it should work correctly.

The contextPath of a Servlet Web application defines the root path prefix that the applications will run under. When your app is deployed into a Servlet Web container, you will typically assign a contextPath to the app in the container's configuration, but sometimes containers will default this path using the name of the directory or WAR file that the app is running from.

The best practice is to generate your URL paths in a way that doesn't require a specific root context path. By using full paths that are constructed by prefixing HttpServletRequest.getContextPath() or by using relative URLs, your applications will work properly even if the contextPath of the application is changed.

The next-to-best practice would be to setup your local application environment to use the same context path that the app will be deployed with, which is an empty root context path (commonly thought of a / context path).

These links might also be helpful

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top