java - passing variable from servlet to jsp doesn't work -
i have problem passing object servlet jsp.
servlet.java
@override protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { controller test = new controller(); test.setobjects(); request.getsession().setattribute("item", test.node_1); request.getrequestdispatcher("index.jsp").forward(request, response); }
index.jsp
<title> ${item.firstname} </title>
web.xml
<?xml version="1.0" encoding="utf-8"?> <web-app version="3.0" 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_3_0.xsd"> <servlet> <servlet-name>servlet</servlet-name> <servlet-class>socialgraphui.servlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>servlet</servlet-name> <url-pattern>/servlet</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> </web-app>
tomcat output
okt 25, 2014 6:17:14 pm org.apache.catalina.startup.hostconfig deleteredeployresources info: undeploying context [] okt 25, 2014 6:17:14 pm org.apache.catalina.startup.hostconfig deploydescriptor info: deploying configuration descriptor /library/java/servers/apache-tomcat-7.0.42/conf/catalina/localhost/root.xml okt 25, 2014 6:17:14 pm org.apache.catalina.util.lifecyclebase start info: start() method called on component [standardengine[catalina].standardhost[localhost].standardcontext[]] after start() had been called. sec phone call ignored.
in browser console no error or warning message. please help me how can find out wrong?
check url follow should be:
http://localhost:8080/your project name/servlet
also if item.getfirstname
returns null see nil in tags
to sure param passing jsp page alter item
value string example
request.getsession.setattribute('item' , 'my title');
now if see my title in <title>
tag passing param done , reason in object.
java jsp java-ee servlets
No comments:
Post a Comment