wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Servlet Mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Servlet Mapping" Watch "Servlet Mapping" New topic
Author

Servlet Mapping

italo matos
Greenhorn

Joined: Jul 14, 2009
Posts: 5
i have in my web.xml:

...
<servlet>
<servlet-name>LoginController</servlet-name>
<servlet-class>scwcd.controller.LoginController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginController</servlet-name>
<url-pattern>/Login.do</url-pattern>
</servlet-mapping>


The Application URL is : http://localhost:8080/scwcdApp/ ok ?
in my form, i have:
...
<form action="/Login.do">
...
</form>

but, when i submit the form, i get page not found, because it sends to http://localhost:8080/Login.do

How can to do, form submit to http://localhost:8080/scwcd/Login.do ?






SCJP 6.0
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183


Sends it to your server root, not web app root.

you would have to use /scwcdApp/Login.do (given scwcdApp is your web app name)


JDBCSupport - An easy to use, light-weight JDBC framework -
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3060
    
  38

Sebastian Janisch wrote:you would have to use /scwcdApp/Login.do (given scwcdApp is your web app name)

You can simply use <form action="Login.do">


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
italo matos
Greenhorn

Joined: Jul 14, 2009
Posts: 5
Ok, but then i will to change all /Login.do to /scwcdApp/Login.do , and when i will do deploy, i will change again ?



Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3060
    
  38

italo matos wrote:Ok, but then i will to change all /Login.do to /scwcdApp/Login.do , and when i will do deploy, i will change again ?

Again, you can simply use <form action="Login.do">
No need to mention the web application root name explicitly.
italo matos
Greenhorn

Joined: Jul 14, 2009
Posts: 5
Devaka Cooray wrote:
italo matos wrote:Ok, but then i will to change all /Login.do to /scwcdApp/Login.do , and when i will do deploy, i will change again ?

Again, you can simply use <form action="Login.do">
No need to mention the web application root name explicitly.


but my jsp page, is in other directory (/scwcd/pages/)

Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3060
    
  38

Try to change the action as <form action="../Login.do"> it may work.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

You could use ${pageContext.request.contextPath}/Login.do


[My Blog]
All roads lead to JavaRanch
 
Consider Paul's rocket mass heater.
 
subject: Servlet Mapping