File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Prob with Web application structure

 
Shashank Sharma
Ranch Hand
Posts: 91
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I am having trouble setting my web application
project structure is eclipse is as under


football

--src
--/controller
--AddLeagueServlet.java
--/model
--League.java
--/view
--ListLeagueServlet.java
-- some external jars
--web
--/META-INF
--META INF
--/WEB-INF
--/jsp
--admin
--add_league.html
--/lib
--web.xml
--index.html


so this is the directory structure I am following.
and here is the deployment descriptor

it works fine for list league servlet but on submission of form in add_league .html the container could not find
"HTTP Status 404 - /football/jsp/admin/add_league"

here is the form header

I am using eclipse IDE . Why is container looking for add_league.do (i.e AddLeagueServlet) in /jsp/admin.
Do i have to manually place the class files in the admin folder?
I think class files should be automatically placed in tomcat/webapps/football/WEB-INF/classes/ directory.

Please help

thanks in advance
 
olivier dutranoit
Ranch Hand
Posts: 81
IBM DB2 Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think the problem is that you are posting from and to the wrong directory.

as i understand, you are doing a POST from /football/jsp/admin/add_league.html ...

in your form you have action='add_league.do'

so the i think you are posting to /football/jsp/admin/add_league.do, and this doesn't exist...

try putting in your web.xml <url-pattern>*/add_league.do</url-pattern> instead of <url-pattern>/add_league.do</url-pattern>

(or change your post-action attribute so that it posts to the rightplace in football/add_league.do)


this should do the job i think...

 
Shashank Sharma
Ranch Hand
Posts: 91
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hii

It worked.
What I did was instead of adding of add_league.do in the form action I have used the the complete path of the servlet.
But that is kind of hard coded the name of the servlet. instead of using a different name in the xml for servlet mapping.


as i understand, you are doing a POST from /football/jsp/admin/add_league.html ...
in your form you have action='add_league.do'
so the i think you are posting to /football/jsp/admin/add_league.do, and this doesn't exist...

Can you please explain how is calling a POST method dependent on the location from where you are calling a POST ,which was the problem in my code.

that would be really a help because my app is running but need to understand the concept for calling POST.

thanks





 
olivier dutranoit
Ranch Hand
Posts: 81
IBM DB2 Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

No need to use absolute hard coded paths.
you are using relative paths...
you can simply change to <form action='/add_league.do' method='POST'>
See the "/" before add_league.do
this means the root of your webapp.
If you don't put it there, you will be posting to /football/jsp/admin/add_league.do

1 - "/" means right under the root
2 - nothing means that you want it in the same dir as you are working on
3 - "../" means to go one dir higher

its the same for the anchor tag etc...

in addition to that, you can use your web.xml for extra manipulation etc...

search google for "html relative paths"
 
Shashank Sharma
Ranch Hand
Posts: 91
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic