•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 361,546 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,032 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 1240 | Replies: 4 | Solved
![]() |
•
•
Join Date: Apr 2008
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hi all,
I'm a novice at using jsp and web design in general and have been trying to pass parameters between pages for a good few hours now but to no avail...
Furthermore my classification of the problem may be inaccurate, please understand that I've only been using jsp pages for about a month now.
In short, I'm trying to obtain input from a user via a textbox, then pass that value to another jsp page and my code goes something like this:
I try and retrieve the value entered by the user as follows:
I try and call the new link with the parameters as follows:
When using request.getParameter(sName) on the next page no value is returned unless I physically hardcode the value of sName in the code snippet above.
Any advice would be appreciated,
Thanks alot.
I'm a novice at using jsp and web design in general and have been trying to pass parameters between pages for a good few hours now but to no avail...
Furthermore my classification of the problem may be inaccurate, please understand that I've only been using jsp pages for about a month now.
In short, I'm trying to obtain input from a user via a textbox, then pass that value to another jsp page and my code goes something like this:
I try and retrieve the value entered by the user as follows:
out.println("<tr>");
out.println("<td>   Please enter your surname</td>");
out.println("<td><input type='textarea' name='sSurname' ></td>");
out.println("</tr>"); I try and call the new link with the parameters as follows:
out.println("<a href = 'newuser.account.created.jsp?sName='+sName.value+''> Create Account man</a>");When using request.getParameter(sName) on the next page no value is returned unless I physically hardcode the value of sName in the code snippet above.
Any advice would be appreciated,
Thanks alot.
•
•
Join Date: Mar 2008
Posts: 68
Reputation:
Rep Power: 1
Solved Threads: 5
I too am new to jsps, but i do know that u will have to submit the form. use a submit button.
your code should look something like this
the text that u entered in username will then get posted to the next jsp page and the url will then look something like 'yourjsppage.jsp?username=blahblah'
On the next page u will be able to use request.getParameter() to get the value of the text field.
Hope this helps
your code should look something like this
<form name="testform" id="testform" method="post" action="/yourjsppage.jsp"> <input type ="text" name="username" id="username" /> </form> <input type="submit" name="submitme" value="submit" />
the text that u entered in username will then get posted to the next jsp page and the url will then look something like 'yourjsppage.jsp?username=blahblah'
On the next page u will be able to use request.getParameter() to get the value of the text field.
Hope this helps
•
•
Join Date: Apr 2008
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks for taking the time and effort to respond, perhaps I should try and incorporate your advice into the code.
Web design is pretty new to me coming from a C++/java background. The whole notion of client side/server side scripting is slowly beginning to make sense though...
At present:
I've used a javascript function that uses getElementById and then opens the page in a new window (it's probably not ideal but it served as a start I guess).
In any case, for those who are interested, here's the js function in the head section of my webpage:
Here's the code in the jsp tags:
So after I enter an email address and click on the link, my information gets passed onto the next page which is opened in a new window. I guess the next step involves opening the link in the current window instead of opening a new one.
Kind Regards,
lum1n0us.
Web design is pretty new to me coming from a C++/java background. The whole notion of client side/server side scripting is slowly beginning to make sense though...At present:
I've used a javascript function that uses getElementById and then opens the page in a new window (it's probably not ideal but it served as a start I guess).
In any case, for those who are interested, here's the js function in the head section of my webpage:
<script type="text/javascript">
function myfunction() {
var email = document.getElementById('emailtextarea').value
var link = "user.details.found.jsp?sUserEmailAddress="+email;
window.open(link);
}
</script>Here's the code in the jsp tags:
out.println("<a href = javascript:myfunction(); style='color:#FF5F00;'> Email me my login details</a>");So after I enter an email address and click on the link, my information gets passed onto the next page which is opened in a new window. I guess the next step involves opening the link in the current window instead of opening a new one.
Kind Regards,
lum1n0us.
Considering that you are ready to learn, you need to look at some good tutorials posted at Suns' J2EE site which has everything you need to know about JSP's and much more. They also have a sample application which will serve as a good reference. A good book like Head First Servlet's and JSP's should make you more than an expert on the topic though and is a must read once you grasp the basics.
Last edited by ~s.o.s~ : Apr 9th, 2008 at 1:55 pm.
"I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
•
•
Join Date: Apr 2008
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks for the web reference; I've managed to invest some time in reading over some of the introductory tutorials. If anything I'm beginning to understand the fundamental purpose and suited usage of jsp pages. Will most probably continue to learn on a gradual basis and hopefully become proficient in time to come.
Kind Regards,
lum1n0us.
Kind Regards,
lum1n0us.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
Other Threads in the JSP Forum
- Previous Thread: json loop in a jsp page
- Next Thread: Cookies and JSP website



Linear Mode