I use GAE and struts. When I input htpp://localhost:8888, it will autoload index.jsp.
What I need is for it to process an action immediately.
For example, when I input htpp://localhost:8888, it will autoload action "index.a" instead of autoloading the index.jsp page.
I tried using struts without GAE and it worked correctly. But after I added GAE to my project it would't work. What is the problem and how do I correct it?
Try adding <welcome-file-list> to your web.xml file:
<welcome-file-list>
<welcome-file>index.a</welcome-file>
</welcome-file-list>
Related
I have a web application where I would like to tie a JSP to address http://host:port/status and a servlet to addresses like http://host:port/status/.... Is this possible? According to this article it should be possible ("container prefers an exact path match over a wildcard path match") at least for some containers and the Java Servlet Specification contains similar examples (albeit without wildcard, on p. 12-123 in April 2013 version), but if I try the following in web.xml it appears as if the JSP is never called and all requests (also to http://host:port/status) are routed to the servlet. My JSP and servlet are hosted on Google App Engine.
<servlet>
<servlet-name>Status</servlet-name>
<jsp-file>/Status.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>Status</servlet-name>
<url-pattern>/status</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>StatusUpload</servlet-name>
<servlet-class>com.example.StatusUploadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>StatusUpload</servlet-name>
<url-pattern>/status/*</url-pattern>
</servlet-mapping>
Instead of mapping the same url to two different JSPs/Servlets in web.xml you can use a URL Rewriting filter like Tuckey UrlRewriteFilter which uses a configuration file urlrewrite.xml which would also be placed in WEB-INF. It uses regex in the rules.
These two rules should do what you want:
<rule>
<from>^/status$</from>
<to>/Status.jsp</to>
</rule>
<rule>
<from>^/status/(.*)$</from>
<to>/StatusUpload/?param=$1</to>
</rule>
Then in WEB-INF you would not map the JSP anymore but would map the Servlet to StatusUpload. When the user goes to /status/postfix the URL Rewriting filter will forward to the servlet (with the postfix part passed as a parameter) in the backend without the address the user sees in the address bar changing.
I am running into a problem with invoking JSP files inside a Google App Engine application. Here is an equivalent version of the relevant configuration in web.xml:
<servlet>
<servlet-name>SomeServlet</servlet-name>
<jsp-file>SomeServlet.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>SomeServlet</servlet-name>
<url-pattern>/prefix</url-pattern>
</servlet-mapping>
When I try accessing SomeServletin the development environment at http://localhost:8888/prefixthis works fine, however if I try it in production at http://someapp.appspot.com/prefix I get HTTP error 404 (Not Found). It's war/SomeServlet.jsp in the file system. There is no further information in the server logs. I have also tried various access control configurations but to no avail.
What could be the reason for this failure?
You should use:
<jsp-file>/SomeServlet.jsp</jsp-file>
From the documentation:
Note: The <jsp-file> must start with a forward slash (/) if the JSP is
in the application's root directory.
I have a gwt application that have some servlet on it. During development mode, the servlet can be accessed properly but when deployed I can't access it like:
Debug mode:
http://127.0.0.1:8888/mygwtapp/greet (Works)
Deployed in Appspot.com
http://mygwtapp123456.appspot.com/mygwtapp/greet (Does not work)
What could be the problem?
Here's the mapping on the web.xml
<servlet>
<servlet-name>greet</servlet-name>
<servlet-class>com.mygwtapp.server.GreetServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greet</servlet-name>
<url-pattern>/mygwtapp/greet</url-pattern>
</servlet-mapping>
Why aren't you using http://mygwtapp123456.appspot.com/mygwtapp/greet when deployed, when this is what you mapped in your web.xml?
Are you sure you've updated your default version in appengine control panel? If you updated version id in appengine-web.xml, but haven't set that as default, your appspot could be serving a web.xml that doesn't have your updated servlet.
If this is not the issue, please respond with any additional logging / error messages you encounter.
In my application, i need to process all the requests from users in a single servlet, however, i happen to have a folder with static content, which i would like to also serve statically.
In my web.xml file, i have the following:
<servlet>
<servlet-name>all</servlet-name>
<servlet-class>a.b.c.WidgetlistXml</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>all</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Is there a way i can exclude, say, all .zip files from this?
PS. I know this has been asked on StackOverflow before, but the latest posts were from about 2006, and they also concerned Spring or other frameworks. I use none, and since 2006 something could have changed in url-patterns. By the way, finding the docs on web.xml is not that simple either.
Thank you in advance.
Set a DefaultServlet for your static contents. Here is an example:
http://tomcat.apache.org/tomcat-7.0-doc/default-servlet.html#where
When I modify the web.xml for my tomcat6 application, the console print:
"Undeploying context []"
and seems tomcat reloading my app.
I don't want this "hot reloading", how to disable this behavior?
you can disable this by changing the value to false in server.xml file.
autoDeploy="false"