• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

basic jsp

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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='"<c:out value="${param.strFname}">"'>

Please help.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by liliya woland:

<INPUT type="text" id="fname" value='"<c:out 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.
 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this

<c:set var="something">
value
</c:set>
[ July 19, 2006: Message edited by: Pavel Kubal ]
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 <c:out value="${param.fname}"/> and <c:out 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?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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:

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the help. I got my script to work; the problem was related to html and not jsp.
reply
    Bookmark Topic Watch Topic
  • New Topic