This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi, I have one main.jsp page which has some form fields and submit button. on submit it goes to page called page2.jsp. When user clicks on browser back button, getting warning as
Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you. To resubmit your information and view this Web page, click the Refresh button. when I click on refresh it takes me to main.jsp page. how to refresh and reload the page when user clicks Browser back button? Thanks, Padmashree
Rajendar Goud
Ranch Hand
Joined: Mar 06, 2002
Posts: 220
posted
0
Hi padma, This may be related to setting the scope of the jsp page.u might have set the scope to 'request' . try putting it to session. i may be wrong also ??? Raj
padma patil
Ranch Hand
Joined: Nov 06, 2001
Posts: 41
posted
0
Hi Rajendra, I am not using any Java beans where I can set the scope. How I can set the scope to session in JSP? - padma
Have u given any no-cache instruction like this <meta HTTP-EQUIV="Pragma" CONTENT="no-cache> or set any response headers directing the browser not to cache the page.
Hi padma, If possible,can u send the code,so that can have a look at it .. Raj
Rajendar Goud
Ranch Hand
Joined: Mar 06, 2002
Posts: 220
posted
0
hi padma, i just tried a simple jsp example ,by submitting a single field. iam able to get back to the main page by hitting the back button and is not throwing any exception.please take a look at this example. it got 2 files test1.jsp <html> <body> <form action="test2.jsp" method = "post"> Enter a name please <br><input type ="text" name ="t1"> <input type = "submit" value = "submit"> </form> </html> and test2.jsp
<html> <%@ page session="true" %> The Name u Entered is : <%String i = request.getParameter("t1");%> <b><%= i%></b> </html> Raj
trupti nigam
Ranch Hand
Joined: Jun 21, 2001
Posts: 602
posted
0
Hi Rajendar, My question is very similar to the above one. I am getting the null pointer exception.can you please look into the code. Error: 500 Location: /examples/jsp/myJsp/sayHello.jsp Internal Servlet Error: org.apache.jasper.JasperException at org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibrary.java:200) at org.apache.jasper.runtime.JspRuntimeLibrary.introspect(JspRuntimeLibrary.java:148) at jsp.myJsp.sayHello_2._jspService(sayHello_2.java:86) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574) at org.apache.tomcat.core.Handler.invoke(Handler.java:322) at org.apache.tomcat.core.Handler.service(Handler.java:235) at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833) at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516) at java.lang.Thread.run(Thread.java:484) Root cause: java.lang.NullPointerException at org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibrary.java:162) at org.apache.jasper.runtime.JspRuntimeLibrary.introspect(JspRuntimeLibrary.java:148) at jsp.myJsp.sayHello_2._jspService(sayHello_2.java:86) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574) at org.apache.tomcat.core.Handler.invoke(Handler.java:322) at org.apache.tomcat.core.Handler.service(Handler.java:235) at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833) at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516) at java.lang.Thread.run(Thread.java:484) sayHello.jsp <%@ page import= "myJsp.name" %> <jsp:useBean id="nameBean" class="myJsp.name" /> <jsp:setProperty name="inputName" property="*"/> <html> <head> <title> My First JSP page.</title> </head> <body bgcolor = "00ff00" text = "black"> <font size= 5> Hello!! I am Pradnya.<p> <form method=get> What's your name? <input type=text name=inputName> <input type = submit value="Submit"> </form> <% if ( request.getParameter("inputName") != null ) { %> <%@ include file="/jsp/myJsp/name2.jsp" %> <% } %> </font> </body> </html> name2.jsp <html> <head> <title> My First JSP page.</title> </head> <body bgcolor = "yellow" text= "red"> <%@ page session="true" %> <h2> Hello !!! <jsp:getProperty name="nameBean1" property="inputName" />! Hope you'r enjoying this session. </h2> </body> </html> name.java (the bean) package myJsp; public class name {
Hi, The problem lies here <jsp:getProperty name="nameBean1" property="inputName" />! The name attribute is ="nameBean1" but where have u created the bean with that name using jsp:useBean tag? Unless u create an instance of the bean u cannot call jsp:getProperty tag.The property name should be "name" and not "inputName". The property name is decided based on setter and getter methods and not on the actual variable name declared in the bean. In ur case getName and setName so the property is "name".
Rajendar Goud
Ranch Hand
Joined: Mar 06, 2002
Posts: 220
posted
0
Hi Trupti, i hope u got what pradeep said, u need to create an instance of a bean and for that ,the attribute which u mentioned in <jsp:useBean id="nameBean" class="myJsp.name" /> must be similar to the 'name' attribute which u use in the 'get' and 'set' properties. it shouldnt be <jsp:getProperty name="nameBean1" property="inputName" /> but <jsp:getProperty name="nameBean" property="inputName" /> .if u want u can take the example which i wrote ...
For property = "*" to work u need to use matching form field names .. if the property name in the bean is "name" ur text field name must also be "name" which is not the case in ur form.. plz change the text field name to "name"... and when u retrieve the property using jsp:getProperty pass "name" to property attribute.. Hope this helps! Good Luck
trupti nigam
Ranch Hand
Joined: Jun 21, 2001
Posts: 602
posted
0
Hi, I have done the changes in my code as told by you. like in sayHello.java %@ page import= "myJsp.name" %> <jsp:useBean id="nameBean" class="myJsp.name" /> <jsp:setProperty name="name" property="*"/> <html> <head> <title> My First JSP page.</title> </head> <body bgcolor = "00ff00" text = "black"> <font size= 5> Hello!! I am Pradnya.<p> <form method= get> What's your name? <input type=text name=name> <input type = submit value="Submit"> </form> <% if (request.getParameter("name") != null ) { %> <%@ include file="/jsp/myJsp/name2.jsp" %> in name2.jsp <h2> Hello !!! <jsp:getProperty name = "nameBean" property="name"/>! Hope you'r enjoying this session. and the bean private String inputName;
public String getName() { return inputName; }
public void setName(String name) { inputName = name; }
but still i am getting the null pointer exception. I am using tomcat3.1.1 The first JSp appears correctly but when i enter the name instead of the second jsp page i am getting the above error. Thanks, Trupti
Rajendar Goud
Ranch Hand
Joined: Mar 06, 2002
Posts: 220
posted
0
Trupti, The ID attribute of the bean must be the same as the 'name' attribute u use in the get and set methods.. so it must be , <jsp:useBean id="nameBean" class="myJsp.name" /> <jsp:setProperty name="nameBean" property="*"/> <jsp:getProperty name = "nameBean" property="name"/> check this out and try compiling.. Raj
trupti nigam
Ranch Hand
Joined: Jun 21, 2001
Posts: 602
posted
0
With the following code changes i am getting the following error..
error Error: 500 Location: /examples/jsp/myJsp/sayHello.jsp Internal Servlet Error: org.apache.jasper.JasperException: Cannot find any information on property 'inputName' in a bean of type 'myJsp.Name' at org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:612) at org.apache.jasper.compiler.GetPropertyGenerator.generate(GetPropertyGenerator.java:101) at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.generate(JspParseEventListener.java:792) at org.apache.jasper.compiler.JspParseEventListener.generateAll(JspParseEventListener.java:221) at org.apache.jasper.compiler.JspParseEventListener.endPageProcessing(JspParseEventListener.java:176) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:210) at org.apache.tomcat.facade.JasperLiaison.jsp2java(JspInterceptor.java:790) at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:731) at org.apache.tomcat.facade.JspInterceptor.requestMap(JspInterceptor.java:506) at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:968) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:875) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833) at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516) at java.lang.Thread.run(Thread.java:484) the sayHello.jsp <%@ page import= "myJsp.Name" %> <jsp:useBean id="nameBean" class="myJsp.Name" scope = "session" /> <jsp:setProperty name="inputName" property="*"/> <html> <head> <title> My First JSP page.</title> </head> <body bgcolor = "00ff00" text = "black"> <font size= 5> Hello!! I am Pradnya.<p> <form method= get> What's your name? <input type=text name=yourName> <input type = submit value="Submit"> </form> <% if (request.getParameter("yourName") != null ) { %> <%@ include file="/jsp/myJsp/name2.jsp" %> <% } %> the name2.jsp <%@ page import= "myJsp.Name" %> <jsp:useBean id="nameBean1" class="myJsp.Name" scope = "session" /> <html> <head> <title> My First JSP page.</title> </head> <body bgcolor = "yellow" text= "red"> <h2> Hello !!! <jsp:getProperty name = "nameBean" property="inputName"/>! Hope you'r enjoying this session. </h2> </body> </html> the bean name.java package myJsp; public class Name {
private String yourName;
public String getName() { return yourName; }
public void setName(String inputName) { yourName = inputName; }
}
thanks, Trupti
Rajendar Goud
Ranch Hand
Joined: Mar 06, 2002
Posts: 220
posted
0
Trupti, still the code seems to be confusing and unclear with the name attributes is concerned.
Here is the corrected code of ur actual code.please copy this and test it out.... <%@ page import= "myJsp.Name" %> <jsp:useBean id="nameBean" class="myJsp.Name" scope = "session" /> <jsp:setProperty name="nameBean" property="*"/> <html> <head> <title> My First JSP page.</title> </head> <body bgcolor = "00ff00" text = "black"> <font size= 5> Hello!! I am Pradnya.<p> <form method= get> What's your name? <input type=text name=yourName> <input type = submit value="Submit"> </form> <% if (request.getParameter("yourName") != null ) { %> <%@ include file="/jsp/myJsp/name2.jsp" %> <% } %> the name2.jsp <%@ page import= "myJsp.Name" %> <jsp:useBean id="nameBean1" class="myJsp.Name" scope = "session" /> <html> <head> <title> My First JSP page.</title> </head> <body bgcolor = "yellow" text= "red"> <h2> Hello !!! <jsp:getProperty name = "nameBean1" property="inputName"/>! Hope you'r enjoying this session. </h2> </body> </html> the bean name.java package myJsp; public class Name { private String yourName; public String getName() { return yourName; } public void setName(String inputName) { yourName = inputName; }
}
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.