jsp - Servlets and Spring Integration -
i'm new in jsp , servlets,
web.xml file
<?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>loginpage</servlet-name> <servlet-class>com.planner.servlet.loginpage</servlet-class> </servlet> <servlet-mapping> <servlet-name>loginpage</servlet-name> <url-pattern>/loginpage</url-pattern> </servlet-mapping> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/applicationcontextbl.xml</param-value> </context-param> </web-app>
index.jsp file
<%@ 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> <form method="post" action="/loginpage"> <table border="1"> <tr> <td>login</td> <td><input type="text" name="login" /> </td> </tr> <tr> <td>senha:</td> <td><input type="password" name="pass" /></td> </tr> <tr> <input type="submit" value="entrar" /> </tr> </table> </form> </body> </html>
loginpage.java
package com.planner.servlet; import java.io.ioexception; import java.io.printwriter; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import org.springframework.beans.factory.config.autowirecapablebeanfactory; import org.springframework.web.context.webapplicationcontext; import org.springframework.web.context.support.webapplicationcontextutils; /** * servlet implementation class loginpage */ public class loginpage extends httpservlet { private static final long serialversionuid = 1l; /** * @see httpservlet#httpservlet() */ public loginpage() { super(); } @override public void init() throws servletexception { webapplicationcontext ctx = webapplicationcontextutils.getrequiredwebapplicationcontext(getservletcontext()); autowirecapablebeanfactory bf = ctx.getautowirecapablebeanfactory(); // bf.autowirebean(this); } /** * @see httpservlet#doget(httpservletrequest request, httpservletresponse * response) */ protected void service(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { printwriter out = response.getwriter(); out.println("<html>"); out.println("<head>"); out.println("<title> teste </title>"); out.println("</head>"); out.println("<body>"); out.println("hello world!"); out.println("</body>"); out.println("</html>"); } }
problem: when click on submit button, shows me error:
**type status report message /apontador_web/loginpage description requested resource not available.**
and when remove tags "listener" , "context-param" loads servlet.
what can happening?
go glashfish server output , exception
tell me name off exception
Comments
Post a Comment