aspose file tools*
The moose likes Other Application Frameworks and the fly likes Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Spring" Watch "Spring" New topic
Author

Spring

kate pal
Greenhorn

Joined: Sep 25, 2008
Posts: 9
Hello All ,

I am trying very basic spring application
below is the xml files

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>


<bean name="/home.htm" class="com.test.controller.testController">
<property name="greeting">
<value>Welcome to Spring Training!</value>
</property>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>

</beans>
this is training-servlet.xml

and below is web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<display-name>springMvc</display-name>

<servlet>
<servlet-name>training</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>training</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>



</web-app>

-----------------------------
testController.java

package com.test.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class testController implements Controller{

public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
return new ModelAndView("home", "message", greeting);
}
private String greeting;
public void setGreeting(String greeting) {
this.greeting = greeting;
}
}
-------------------------------------------------

home.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<% out.println(" ==> home" ); %>
</body>
</html>

I kept all neccessary .jar in my classpath

when I deploy this application I got
HTTP Status 404 - /springMvc/home.htm

--------------------------------------------------------------------------------

type Status report

message /springMvc/home.htm

description The requested resource (/springMvc/home.htm) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.26
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Have you looked at any of the Tomcat logs to see what, if anything, is going wrong? and what is the directory structure of your web app and where, exactly is it located on your machine?
and also check into your tomcat manager to check the status of your application.
[ October 11, 2008: Message edited by: Muhammad Saifuddin ]

Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Try the servlet mapping in your web.xml. Maybe it just needs a "/" in from of the URL mapping. That is where I always make my mistakes.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring