• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

popup form - howto get data ? from newbie

 
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's a popup form? Is this to do with JavaScript?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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()
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !!
 
chen hongyun
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can save selected data in HttpSession when user click "next"
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
do you mind to show me how to do that ? i'm new in jsp ...thank you for your time
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
request.getSession().setAttribute("page3", data);
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
from getsession.jsp , how do i get the values that type by user ? say "emailbutton" and "emailbutton2" text field ....thank you !!
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, this is the source code that i mentioned, if i put "String email" as shown, it will generate error ? why is it so ?

 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anyone think i did wrongly ...i think may be cause by p2p software like edonkey s/w
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to print stacktrace ? adeel ?
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
error is shown on upper thread
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nothing to say. just make sure that you are using <%%> instead of <%= %>
 
pie. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic