- This topic has 1 reply, 2 voices, and was last updated 18 years, 5 months ago by Riyad Kalla.
-
AuthorPosts
-
amir55Participanthi dear
just to make life easy. I will copy the problem. three files.1 – JavaClient is working perfect it is from internet tutorial
***************************************
public class JavaClient
{public static void main(String args[]) throws Exception
{
try
{
System.out.println(“point1”);
Resource res = new ClassPathResource(“hello.xml”);
System.out.println(“point2”);
BeanFactory factory = new XmlBeanFactory(res);
System.out.println(“point3”);
Hello bean1 = (Hello) factory.getBean(“hello”);
// String s = bean1.sayhello(args[0]);
String s = bean1.sayhello(“Amir”);
System.out.println(s);
}catch(Exception e1){System.out.println(“”+e1);}
}
}
**************************************************
2 – ServletClient from the internet not working as it misses web.xmlpublic class ServletClient extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException
{
resp.setContentType(“text/html”);
PrintWriter out =resp.getWriter();
String a = req.getParameter(“text1”);
try
{
System.out.println(“point1”);
Resource res = new ClassPathResource(“hello.xml”);
System.out.println(“point2”);
BeanFactory factory = new XmlBeanFactory(res);
System.out.println(“point3”);
Hello bean1 = (Hello)factory.getBean(“hello”);
String s = bean1.sayhello(a);
out.println(s);
}catch(Exception e1){System.out.println(“”+e1);}
}
}3 – web.xml that I attempted to create which the one needs yuor attention and correction
<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app version=”2.4″
xmlns=”http://java.sun.com/xml/ns/j2ee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”>
<servlet>
<servlet-name>helloProject</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>ServletClient</servlet-name>
<servlet-class>test.ServletClient</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletClient</servlet-name>
<url-pattern>/ServletClient</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>hello.xml</param-value>
</context-param>
<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
</servlet><!–listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener–>
</web-app>***********************************************
or I can zip u the whole program if u do not mind
thnaks a lot
Riyad KallaMemberYou need to ask your question in more detail, I don’t understand what you are requesting.
-
AuthorPosts