Forums Register Login

popup form - howto get data ? from newbie

+Pie Number of slices to send: Send
hi,good day, everyone ,i want to keep user setting values from popup form(multiple pages), can anyone guide me how to get alll data that user select or keyin in popup form in jsp ?...thank you very much for helping !!
[ September 28, 2004: Message edited by: Alvin chew ]
+Pie Number of slices to send: Send
What's a popup form? Is this to do with JavaScript?
+Pie Number of slices to send: Send
you can do it like this
page1.jsp:
<html>
<head><b>session 1</b></head>
<body>
<%
String emailbutton = (String) session.getAttribute("emailbutton");
%>
<form name="form1" method="post" action="page2.jsp">
email : <input type="text" name="emailbutton" value="<%= emailbutton%>">
<input type="submit" name="Submit" value="call">
</form>
</body>
</html>

page2.jsp:
<html>
<head><b>session 2</b></head>
<body>
<%
session.setAttribute("emailbutton",(String) request.getParameter("emailbutton"));
String emailbutton = (String) session.getAttribute("emailbutton");
String emailbutton2 = (String) sessin.getAttribute("emailbutton2");
%>
<form name="form1" method="post" action="page3.jsp">
<%
out.println("we get emailbutton:" + emailbutton + " from session");
%>
job : <input type="text" name="emailbutton2" value="<%= emailbutton2%>">
<input type="submit" name="Submit" value="call">
</form>
</body>
</html>
+Pie Number of slices to send: Send
thank you, chen , thank you very much for your time and help ...

i have a question, when i type as follow



it generate error (can't get variable), why is it so ? but if i put "String email2" then is ok ...is it a need to follow exactly the name from getAttribute("email2")?

thank you !
+Pie Number of slices to send: Send
How are you setting your attribute. i mean, if you set like this

request.getSession().setAttribute("email2","any");

then you must get like this

session.getAttribute("email2");

if it is like

request.getSession().setAttribute("String email2","any");

then you must get like this

session.getAttribute("String email2");
[ September 27, 2004: Message edited by: adeel ansari ]
+Pie Number of slices to send: Send
thanks for reply adeel , what i actually means is as follow



why i must make email2 then only can prone the error ? i try "String email = (String) session.getAttribute("email2");" , it come up "can't find the variable " error, thank you !
+Pie Number of slices to send: Send
may be your session doesn't have this "email2" attribute. try to get session.getId(). and confirm it that you are accessing the same session, while doing getAttribute().

infact couldn't get you really elaborate more if it is something different. give a snippet of setAttribute() along getAttribute()
+Pie Number of slices to send: Send
hi, dirk, this is actually jsp question

i would like to further my description on this popup

when the popup form display, it actually contains 3 pages, i named it page1, page2 and page3 ..every page contains some textbox and selection for keeping user configuration setting

each page contains "previous" and "next" button, and when user click next button it will goto page2 while user in page1.. and also page2 next button will go page3, however, page3 contain extra button "preview" which allow display user selected data

now, i want to display selected data when user click "preview" button in page3, and these selected data also be save and use for further process

can anyone please suggest or guide me on my case ? thank you very much for your time !!
+Pie Number of slices to send: Send
you can save selected data in HttpSession when user click "next"
+Pie Number of slices to send: Send
do you mind to show me how to do that ? i'm new in jsp ...thank you for your time
+Pie Number of slices to send: Send
request.getSession().setAttribute("page3", data);
+Pie Number of slices to send: Send
this is setsession2.jsp


<html>

<head><b>session 1</b></head>



<body>



<form name="form1" method="post" action="setsession.jsp">

email : <input type="text" name="emailbutton" >


<input type="submit" name="Submit" value="call">

</form>

<%
String mybutton = request.getParameter("emailbutton");
System.out.println("emailbutton:" + mybutton);
session.setAttribute("accessobj2", mybutton);
%>

</body>
</html>

[ September 28, 2004: Message edited by: Alvin chew ]
[ September 28, 2004: Message edited by: Alvin chew ]
+Pie Number of slices to send: Send
this is setsession.jsp

<html>

<head><b>set session 2 </b></head>

<%
session.setAttribute("accessobj", "testing");
%>


<body>



<form name="form18" method="post" action="getsession.jsp">

email : <input type="text" name="emailbutton2" >


<input type="submit" name="Submit2" value="call">

</form>




<!-- <a href="getsession.jsp"> get session </a> -->




</body>


</html>
[ September 28, 2004: Message edited by: Alvin chew ]
+Pie Number of slices to send: Send
this is getsession.jsp

<html>

<head>set session</head>


<body>

<%


String str = (String) session.getAttribute("accessobj");
String str1 = (String) session.getAttribute("accessobj2");

String str2 = (String) request.getParameter("emailbutton");

if(str == null)
{out.println("null");}

else

{out.println("we get :" + str2 +" from getParameter");}

{out.println("we get :" + str +" from session");}

{out.println("we get :" + str1 +" from session");}
%>


</body>


</html>
+Pie Number of slices to send: Send
from getsession.jsp , how do i get the values that type by user ? say "emailbutton" and "emailbutton2" text field ....thank you !!
+Pie Number of slices to send: Send
hi, this is the source code that i mentioned, if i put "String email" as shown, it will generate error ? why is it so ?

+Pie Number of slices to send: Send
anyone think i did wrongly ...i think may be cause by p2p software like edonkey s/w
+Pie Number of slices to send: Send
you mean if you do this,

<%String email = (String) session.getAttribute("email2");%>

then it results in error "can't find the variable"

and if you do this instead,

<%String email2 = (String) session.getAttribute("email2");%>

then it works fine.

i dont think so. could you print the whole StackTrace??
+Pie Number of slices to send: Send
how to print stacktrace ? adeel ?
+Pie Number of slices to send: Send
this is the error i get from tomcat server ..

The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 29 in the jsp file: /jsp/setsession.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\jakarta-tomcat-5.0.12\work\Catalina\localhost\jsp\org\apache\jsp\jsp\setsession_jsp.java:69: cannot find symbol
symbol : variable email2
location: class org.apache.jsp.jsp.setsession_jsp
out.print(email2);
^
1 error


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:413)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


note The full stack trace of the root cause is available in the Tomcat logs.
+Pie Number of slices to send: Send
wht you gettin is a compile time error or a runtime exception??

if exception then do e.printStackTrace() and paste the exception from console.

otherwise, paste the error from the console.

are you using Tomcat as a JSP container?? or something else. please mention.
+Pie Number of slices to send: Send
error is shown on upper thread
+Pie Number of slices to send: Send
nothing to say. just make sure that you are using <%%> instead of <%= %>
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 4201 times.
Similar Threads
Pop up URL authentication
How to refresh the main window once we close the popup
popup window loses variable
how to get value from popup window
disabling and enabling text boxes
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 04:13:34.