Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Servlets
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Servlets
Two forms one web.xml
Angus Ferguson
Ranch Hand
Posts: 1402
3
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi all,
I have an index.jsp which has two buttons one sends data to one form in a
servlet
and the other sends data to another form in another servlet.
<form action="${pageContext.request.contextPath}/UploadDownloadFileServlet" method="post" > Select File to Upload:<input type="file" name="fileName"> <br> <input type="submit" value="Upload"> </form> <form action="${pageContext.request.contextPath}/ControllerLeanRoute" method="get" >
My doubt is how to put two Servlet in the web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> <servlet> <servlet-name>ControllerLeanRoute</servlet-name> <servlet-class>controller.ControllerLeanRoute</servlet-class> </servlet> <servlet-mapping> <servlet-name>ControllerLeanRoute</servlet-name> <url-pattern>/ControllerLeanRoute</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> </web-app>
Any idea, please?
Regards, Isaac
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The deployment descriptor (web.xml) is not limited to a single servlet.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Angus Ferguson
Ranch Hand
Posts: 1402
3
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The thing is that when I run the app with this web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> <servlet> <servlet-name>ControllerLeanRoute</servlet-name> <servlet-class>controller.ControllerLeanRoute</servlet-class> </servlet> <servlet> <servlet-name>UploadDownloadFileServlet</servlet-name> <servlet-class>controller.UploadDownloadFileServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ControllerLeanRoute</servlet-name> <url-pattern>/ControllerLeanRoute</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>UploadDownloadFileServlet</servlet-name> <url-pattern>/UploadDownloadFileServlet</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> </web-app>
but when I comment one of them like this:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> <servlet> <servlet-name>ControllerLeanRoute</servlet-name> <servlet-class>controller.ControllerLeanRoute</servlet-class> </servlet> <!-- <servlet> <servlet-name>UploadDownloadFileServlet</servlet-name> <servlet-class>controller.UploadDownloadFileServlet</servlet-class> </servlet>--> <servlet-mapping> <servlet-name>ControllerLeanRoute</servlet-name> <url-pattern>/ControllerLeanRoute</url-pattern> </servlet-mapping> <!-- <servlet-mapping> <servlet-name>UploadDownloadFileServlet</servlet-name> <url-pattern>/UploadDownloadFileServlet</url-pattern> </servlet-mapping>--> <session-config> <session-timeout> 30 </session-timeout> </session-config> </web-app>
It works. Then error is like this:
eploy?config=file%3A%2Fvar%2Ffolders%2F6_%2Flvjzdzns3njfmtnx38xdwjzr0000gn%2FT%2Fcontext4183162847398574853.xml&path=/LeanRouteREST_SPRING_TDD_MAVEN FAIL - Deployed application at context path /LeanRouteREST_SPRING_TDD_MAVEN but context failed to start
It fails to deploy. I have checked the folder where the files are and all looks rigth.
Any idea, please ?
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
No logged errors regarding parsing the web.xml prior to that?
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Angus Ferguson
Ranch Hand
Posts: 1402
3
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
At the server log of
Tomcat
I got this error:
02-Dec-2015 16:58:46.385 SEVERE [http-nio-8080-exec-58] org.apache.catalina.startup.HostConfig.deployDescriptor Error deploying configuration descriptor /Users/isaac/Documents/servidor/apache-tomcat-8.0.26/conf/Catalina/localhost/LeanRouteREST_SPRING_TDD_MAVEN.xml java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/LeanRouteREST_SPRING_TDD_MAVEN]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:460) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1556) at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497)
But the key is here:
Caused by: java.lang.IllegalArgumentException: The servlets named [UploadDownloadFileServlet] and [controller.UploadDownloadFileServlet] are both mapped to the url-pattern [/UploadDownloadFileServlet] which is not permitted
any idea, please?
Ron McLeod
Marshal
Posts: 4501
572
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Is the servlet annotated with
@WebServlet
as well as being described in web.xml?
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Making attributes from textboxes available to other servlets and storing the latest passed variable.
Redirect to .jsp Spring MVC
doesn't show up bean's attributes in .xhtml
org.apache.catalina.LifecycleException
The requested resource is not available in Netbeans
More...