maya90 (36) [Avatar] Offline
#1
http://www.mayacove.com/jq/chapter8/bootcloset/boot.closet.1.html

I put 'scripts' dir inside dir 'chapter8', (and chg'd ref's accordingly -- & tested with a test.js), but that's only change I made.. I have been doing Tomcat/JSP for about six years.. I don't understand why this is not working...

I added this line,

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

on top of getDetails.jsp, but it's still not working.. help please.. thank you..
bear.bibeault (675) [Avatar] Offline
#2
Re: chapter 8 -- bootcloset ex not working....
The error you are getting is: org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

This means that the JSTL classes or its TLD aren't being loaded. Are you sure that both JSTL jar files are resident in WEB-INF/lib?
maya90 (36) [Avatar] Offline
#3
Re: chapter 8 -- bootcloset ex not working....
my understanding was that if you have an absolute url in directive (http://java.sun.com/jsp/jstl/core, as opposed to something like <%@ taglib uri="c.tld" prefix="c" %>smilie you don't need to specify anything in web.xml... in fact, I have two JSTL's jsp's here,
http://www.mayacove.com/jstltest/coreTags.jsp
http://www.mayacove.com/jstltest/env_vars.jsp

that have directive <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

but no tld's anywhere, and nothing in web.xml.. .. yet they don't throw any errors.. (they both use <c:out...> tag....

(and at any rate, there was no JSTL directive at all inside getDetails.jsp, I added it myself, when I saw it wasn't working..)

well, will continue to investigate.. thank you very much..
bear.bibeault (675) [Avatar] Offline
#4
Re: chapter 8 -- bootcloset ex not working....
>my understanding was that if you have an absolute url in directive
>(http://java.sun.com/jsp/jstl/core, as opposed to something like <%@ taglib uri="c.tld" <br /> >prefix="c" %>smilie you don't need to specify anything in web.xml <br /> <br /> You don't. I didn't say anything about putting anything in the deployment descriptor. <br /> <br /> I said to be sure that the jar files are in WEB-INF/lib.
bear.bibeault (675) [Avatar] Offline
#5
Re: chapter 8 -- bootcloset ex not working....
>(and at any rate, there was no JSTL directive at all inside getDetails.jsp, I added it myself,
> when I saw it wasn't working..)

That's handled by the prelude.
maya90 (36) [Avatar] Offline
#6
Re: chapter 8 -- bootcloset ex not working....
oh brother, was indeed missing JSTL jars.. thank you.. would have to reboot server now to make it work online, don't want to do that.. have it working locally.. thank you very much.. (ok, now for the fun part: figuring out how AJAX works with jQuery....smilie
bear.bibeault (675) [Avatar] Offline
#7
Re: chapter 8 -- bootcloset ex not working....
/thumbs-up
maya90 (36) [Avatar] Offline
#8
Re: chapter 8 -- bootcloset ex not working....
thank you so much Bear.. for your patience and for not saying I'm a jerk b/c I had forgotten the jars (I hadn't done beans stuff in a while..)

I have my little jQuery/Ajax widgets going.. but am having a bit of a hard time figuring out what difference is betw get() and load() methods...

in jQ site it says, for load():
Load data from the server and place the returned HTML into the matched element.
(http://api.jquery.com/load/)

for get() it says:
Load data from the server using a HTTP GET request.
http://api.jquery.com/jQuery.get/

does mean ONLY that get() method can be used only with GET requests and load() method for both GET and POST requests?? or is there more to it than that??

....

actually it doesn't mean what I said above, since it looks like with get() method you can also send data.. oh brother.. pls explain.. thank you very much..
bear.bibeault (675) [Avatar] Offline
#9
Re: chapter 8 -- bootcloset ex not working....
load() is a method on the jQuery object (the wrapped set) that automatically injects the response into the wrapped elements. It will generate a GET or POST request depending on how it is called.

$.get() is a utility function that always performs a GET and returns the response to the callback to do with as you will.

Each is available for different needs. Remember, there are also other utility methods such as $.getJSON(), $.post() and the most general of all: $.ajax().

P.S. The HTML/JavaScript forum at JavaRanch is a great place to get jQuery questions answered: http://www.coderanch.com/forums/f-20/HTML-JavaScript
maya90 (36) [Avatar] Offline
#10
Re: chapter 8 -- bootcloset ex not working....
thank you very much, Bear.. am familiar w/JavaRanch, will check it out for jQuery...

if you could answer one more question please.. am having a bit of hard time understanding this line, in bootcloset/boot.closet.1.html:

$('#detailsDisplay').load( 'getDetails.jsp', { style: selectedStyle } );

in JSP there is: <c:when test="${param.style=='7141832'}"> (to get param passed with element named 'style') ONLY: there is no element named "style" in html... am having a hard time understanding this construct:

{ style: selectedStyle }

in that line... are you giving <select> object (<select id="styleDropdown">smilie name "style" on the fly?? is the code inside the {...} a function being created on the fly? I don't get this.. which one of the params described here

.load( url, [ data ], [ complete(responseText, textStatus, XMLHttpRequest) ] )
(from http://api.jquery.com/load/)

is the code inside the {...}????

and what is "complete"?? is this a call to a fn, and "complete" could be a function named anything?
bear.bibeault (675) [Avatar] Offline
#11
Re: chapter 8 -- bootcloset ex not working....
>ONLY: there is no element named "style" in html... am having a hard time understanding this
> construct: { style: selectedStyle }

It has nothing to do with HTML. That second parameter is a JavaScript object hash with a property named "style", that has a value of selectedStyle.

It is used to form the query parameters that will be sent to the JSP, equivalent to "?style=7141832" (assuming that the value selectedStyle evaluates to 7141832).

This is typical of the way that query parameters will be sent to jQuery Ajax functions -- as an object whose property/values pairs form the request parameters.

>and what is "complete"?

The optional completion callback.
maya90 (36) [Avatar] Offline
#12
Re: chapter 8 -- bootcloset ex not working....
sorry, one more note on boot.closet.1.html:

I changed "styleValue" var name to "selectedStyle" for clarity.. ( I see "style" and I think CSS... at first that's what I thought { style: styleValue } referred to..

that's why in my example the line now reads: { style: selectedStyle }

sorry, and thanks again..
bear.bibeault (675) [Avatar] Offline
#13
Re: chapter 8 -- bootcloset ex not working....
Ah, yes. In this case "style" means "boot style". Just a name.
maya90 (36) [Avatar] Offline
#14
Re: chapter 8 -- bootcloset ex not working....
yes but Bear, how does program know that "style" refers to elem <select id="styleDropdown"> when this element doesn't have name "style".... ??
bear.bibeault (675) [Avatar] Offline
#15
Re: chapter 8 -- bootcloset ex not working....
It has nothing to do with the element. It's just a JavaScript object.
deedee (1) [Avatar] Offline
#16
Re: chapter 8 -- bootcloset ex not working....
> .. am
> having a bit of hard time understanding this line, in
> bootcloset/boot.closet.1.html:
>
> $('#detailsDisplay').load( 'getDetails.jsp',
> { style: selectedStyle } );


if you could answer one more question please.. am having a bit of hard time understanding this line, in bootcloset/boot.closet.1.html:

$('#detailsDisplay').load( 'getDetails.jsp', { style: selectedStyle } );

i have the same problem with load() . So i tried to make an example on my own. i have the same menu and i use load to POST the value to a php file and as it is here : http://www.w3schools.com/php/php_ajax_xml.asp

So i have $('#detailsDisplay').load('data.php', { value1: value } the same way as you have it in the example and i think that load() post value1 to the data.php file so with $q=$_GET["value1"]; i can take the value and use it for the xml file.

but something is wrong...what have i misunderstood ?

and one more ..at the http://api.jquery.com/load/ page says data : A map or string that is sent to the server with the request. if i want to use GET how i do this ? And this isnt the opposite as the book says: if specified, the request is made using the post method.if ommited, the GET is used. ?

sorry for my bad english
teo
bear.bibeault (675) [Avatar] Offline
#17
Re: chapter 8 -- bootcloset ex not working....
I can't guess what your first problem might be. Use Firebug in Firefox to inspect the request to make sure that the request contains the information that you intend. If it does, then the problem must be on the PHP side. If not, post what you find and we'll discuss further.

With regard to GET and POST with load(): if the parameters are specified as a URL-encoded string (e.g. "value1=somevalue") a GET will be used. If the params are specified as an array or object hash (e.g. { value1: "somevalue' }), then a POST will be used. I think I went into more details in the 2nd edition rewrite.

If you need finer control over when POST or GET is used, use one of $.get() or $.post().