Forums Register Login
basic jsp
Can someone help me with the syntax for this:
In my jsp page I get several values in the following manner:

String strFname = rs.getString(1);
String strLname = rs.getString(2);

Now I want to add these two values to input boxes in the same jsp page.
To do this I have the following that doesn't work!

<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<INPUT type="text" id="fname" value='"<cut value="${param.strFname}">"'>

Please help.

Originally posted by liliya woland:

<INPUT type="text" id="fname" value='"<cut value="${param.strFname}">"'>

Since the param builtin scoped variable is a map of all the request paramters submitted to the page, strFname would need to be a request parameter for this to be meaningful.

Yet your post seems to indicate that strFname is a scripting variable.

Which is it?

If it's a scripting variable as your code indicates, it is unavailable to the JSTL and EL. You shouldn't be mixing and matching antiquated (scriptlets) and modern (JSTL/EL) technologies on the same page. It just creates a mess.
Try this

<c:set var="something">
[ July 19, 2006: Message edited by: Pavel Kubal ]
I did try this:
<INPUT type="text" id="fname"
value="+<c:set var="strFname">strFname</c:set>+">

in several combinations without getting the value out. The value is not passed in, it is created in the same page...
I did separate html from jsp page. But now I can only access the first passed in value and no other values. The url reads like this:
http://path/mypage.jsp?fname=val&lname=%20val2 ... and so on

I use <cut value="${param.fname}"/> and <cut value="${param.lname}"/>
to access values, but can get only the first one, fname. Is it possible the %20 makes the second value unaccessible? Is so, is there a way around it?

Originally posted by liliya woland:
I did try this:

Just trying random things that make no sense isn't going to get you much of anywhere. (I don't know what the <c:set> suggestion has to do with your original post.)

Take a moment to back up and figure out what you are really trying to do.

In the example of your fitrst post, since you are using scriplets rather than modern JSP mechanisms, your input element should be:


Originally posted by liliya woland:
But now I can only access the first passed in value and no other values. The url reads like this: ...

OK, now you've really confused me.

Are strFname and strLname scriptlet variables in the JSP as you indicated in your first post, or are they submission parameters passed to the JSP as the result of a form submission or URL with query parameters?
[ July 19, 2006: Message edited by: Bear Bibeault ]
Thank you for the help. I got my script to work; the problem was related to html and not jsp.

This thread has been viewed 859 times.

All times above are in ranch (not your local) time.
The current ranch time is
Dec 10, 2018 09:09:03.