Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

spring 404

 
Abhi Kumar
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reading my post ...

I'm new to Springs and I'm trying a small example...

My web.xml

My Welcome File (Login.jsp)


My Controler is


And Finally
My springapp-servlet.xml is

I'm able to see my Welcome(Login.jsp) but when I click on submit button on the Login page I'm unable to go further I get 404 Server error.
I'm creating a poc.war file and accessing it using the url http://localhost:8080/poc

Any advice is of great help ..
Thanks in advance
Regards
 
Rosco Duncan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are missing the web context from you URL


It should look something like http://localhost:8080/<your app name here>/poc/

Good luck
 
Rosco Duncan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are missing the web context from you URL


It should look something like http://localhost:8080/{your app name here}/poc/

Good luck
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Abhi,

Your try is very good.
You should access your application using http://localhost:8080/YourApplicationName/
That's it. As you have configured welcome file in web.xml , it would be directed automatically to login.jsp.
Actuall problem is not with URL, but url-mapping. Look How do you configure your DispatcherServelet, for which kind of url-pattern it would be invoked? And look at action of login.jsp. Again, look at your handler mapping in spring application context file.
Try to figure this out first, come back and tell us how's it going?
 
Abhi Kumar
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks for your replies
but i have a small query "YourApplicationName/ " is it the name that is given to the DispatcherServlet
i.e in my case "springapp"

Thanks in advance

 
Rosco Duncan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, by default it is the name given to your war file. So if you are producing MyApplication.war, try navigating to http://localhost:8080/MyApplication/poc

See if that works for you.

Cheers.
 
Abhi Kumar
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No,I'm creating war file from command prompt using the command
java -jar poc.war *.*
and I'm running this command front of WEB-INF directory(WEB-INF watching me )
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it's not related to Dispatcher Servlet. It would be your war file name i.e. poc.
It seems that you are using Apache Tomcat. You can navigate to Tomcat Manager and you should find your application entry there. Click on that and see what URL comes up.

You can also explicitly Specify you application name using

entry into web.xml.

@Rosco,
http://localhost:8080/MyApplication/poc
I am unable to understand what would be the value of 'MyApplication'?
 
Rosco Duncan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal Pandya wrote:No, it's not related to Dispatcher Servlet. It would be your war file name i.e. poc.
It seems that you are using Apache Tomcat. You can navigate to Tomcat Manager and you should find your application entry there. Click on that and see what URL comes up.

You can also explicitly Specify you application name using

entry into web.xml.

@Rosco,
http://localhost:8080/MyApplication/poc
I am unable to understand what would be the value of 'MyApplication'?


Its just a place holder for whatever the war file has been called. So in this case it is 'poc'

I think it would be worth trying to navigate to the following URL if you want to be picked up by the Dispatcher Servlet, as I suspect the '/poc/*' that it is mapped to will fall within the '/poc' context that the application is running as.

http://localhost:8080/poc/poc

I could be wrong.

 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rosco Duncan wrote:I could be wrong.

http://faq.javaranch.com/java/AdmitWhenYouAreGuessing
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic