| | |
JSP Page Interaction
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2009
Posts: 81
Reputation:
Solved Threads: 1
Hi,
I'm trying to figure out how to pass parameters across JSP pages without using links. For some reason, I can only get null across...
Here is my code:
Page 1
Page 2:
Thanks,
-Ashton
I'm trying to figure out how to pass parameters across JSP pages without using links. For some reason, I can only get null across...
Here is my code:
Page 1
JSP Syntax (Toggle Plain Text)
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Test Page</title> </head> <body> <form name="testForm" action="Test.jsp"> <select name='tableSelect' onChange='testForm.submit();' style="text-align:center"> <option value='--Select Table--'>--Select Table--</option> <option value='CONFIG_SOURCE'>CONFIG_SOURCE</option> <option value='CONFIG_PROCESS'>CONFIG_PROCESS</option> <option value='CONFIG_PROCESS_SOURCE'>CONFIG_PROCESS_SOURCE</option> <option value='CONFIG_SAL_ROUTING'>CONFIG_SAL_ROUTING</option> </select> </form> <% out.println(request.getParameter("tableSelect")); %> </body> </html>
Page 2:
JSP Syntax (Toggle Plain Text)
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Test Recieve Page</title> </head> <body> <% out.println(request.getParameter("tableSelect")); %> </body> </html>
Thanks,
-Ashton
0
#2 20 Days Ago
I can't see a problem with your page. Does the page submits? Does it go from page A to page B? Is the name of the Test.jsp correct and are the pages in the same folder?
Does onChange works? Should it be onchange?
Also you can try this:
Does onChange works? Should it be onchange?
Also you can try this:
document.testForm.submit(); Check out my New Bike at my Public Profile at the "About Me" tab
•
•
Join Date: Jul 2009
Posts: 81
Reputation:
Solved Threads: 1
0
#4 20 Days Ago
Hi,
Alternatively, could you please tell me why this statement is wrong:
This is servlet code by the way...
Thanks again,
-Ash
Alternatively, could you please tell me why this statement is wrong:
This is servlet code by the way...
JSP Syntax (Toggle Plain Text)
out.println("<select name='tableSelect' onChange=form.submit(); " + request.setAttribute('currentTable', request.getParameter('tableSelect')); + "' style='text-align:center'>");
Thanks again,
-Ash
Last edited by AshtonHogan; 20 Days Ago at 9:46 am.
0
#5 20 Days Ago
First of all request.setAttribute is void. It doesn't return a value to put it in a string.
Secondly:
You just said that it works. Then what is the problem? You cannot just go to a page, refresh it and expect to see data. You say you have Page1 and Page2. Which one is Test.jsp?
When you want to send data to a page you put it at the action. The request is sent to that page:
The data will go to somePage.jsp. This is where you put your code. That page could be even the same. It makes no difference. But the data will go only there.
Secondly:
•
•
•
•
They're both in the same folder. I also added method="post" on Page 1... When I change the selection on Page 1, it works, and it displays what I selected, then when I refresh Page 2, it says null.
When you want to send data to a page you put it at the action. The request is sent to that page:
JSP Syntax (Toggle Plain Text)
<form action="somePage.jsp" > </form>
The data will go to somePage.jsp. This is where you put your code. That page could be even the same. It makes no difference. But the data will go only there.
Check out my New Bike at my Public Profile at the "About Me" tab
![]() |
Similar Threads
- Passing variable value from javascript to jsp page at run time (JSP)
- How to connect Oracle database from JSP page (Java)
- Very Very Urgent...Need Code for Calculating Execution Time For Jsp Page (JSP)
- How to run iReport jrxml from a jsp page (JSP)
- Inserting uft8 strings into MySQL from jsp page (JSP)
- how to connect oracle 8i database with jsp page (JSP)
- Dynamic links in JSP page-need help (JSP)
- how to call javabean from jsp page upon onChange event (JSP)
- date time issue in JSP (JSP)
- I think I'm going to cry... (JSP)
Other Threads in the JSP Forum
- Previous Thread: how to increase users in tomcat-users.xml file automatically not manually
- Next Thread: hi~need some help~
| Thread Tools | Search this Thread |
.net ajax apache c# calling combobox connection database datagridview file frames frameworks functions glassfish integer java javaee javascript jsf jsp mvc2 mvcmodel2 network parameter parameters passing php ping python query read redirect request.getparameter response runtime scriptlets servlet sessions ssl tomcat tutorial







