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:

out.println("<tr>");
out.println("<td>&nbsp;&nbsp&nbsp;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.

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

<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

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:

<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.

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.

This question has already been answered. Start a new discussion instead.