Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!

Bear Bibeault

+ Follow
since Jan 10, 2002
Bear likes ...
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
Merit badge: grant badges
Forum Moderator
Bear Bibeault currently moderates these forums:
Author of:
Secrets of the JavaScript Ninja, 1st and 2nd editions,
jQuery in Action, 1st, 2nd and 3rd editions,
Ajax in Practice, and
Prototype and Scriptaculous in Action
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt Green check
expand Greenhorn Scavenger Hunt Green check

Recent posts by Bear Bibeault

jQuery has no addDefaultText method. Maybe a plugin that's no longer supported?
Not to play forum ping-pong, but we have an Angular forum so this is now there.
What are you expecting this to be evaluating to? (Hint: probably not what you think.)

The likely quickest path to find the input element you want to change is to assign an id and use document.getElementById.

You also probably don't want to do this in a click handler, but rather in a handler for the form's submit event.
2 weeks ago
It probably means your component is in an endless render cycle. Where's the dependency array for your useEffect call?
I'd just code the server end-point to accept a single value and have it return true or false regarding if it's already in use or not. Why return a whole list just to check it on the client side?
Again, a properly formed URL will:
  • start with with the servlet context
  • URL-encode the query parameters

  • <c:out> will not work. Just EL will not work. Explore <c:url> and <c:param>

    If the # is not properly URL-encoded it will never, ever work as part of your param value.

    1 month ago
    Sorry not correct. The # has special meaning in a url (separates the base URL from an anchor tag), regardless of where it is placed, and must be URL-encoded.
    1 month ago
    The query parameter needs to be encoded use URL encoding to ensure that special characters such as # are properly encoded. Neither of <c:out> or the expression language will do this.

    One way is to use <c:url> with <c:param>.
    1 month ago

    Tim Holloway wrote:But also the most likely to bite you.

    Will have to disagree on this point. The safest and best-practice approach is to use server-relative URLs, and dynamically obtain the context path. That way the code works regardless of where it is deployed, immune to changes in context paths external to the application, and adopting the protocol of the page (thus avoiding protocol mismatch errors).

    The latter point is less important than it used to be with browsers enforcing the use of secure protocols.

    (This all assumes a servlet/JSP environment -- best practices may be different for JSF, and are certainly different for modern JS/TypeScript apps.)
    2 months ago
    And Tim's point about the GET is spot on; if you need a POST you'll either need to use a form, or use Ajax.
    2 months ago

    Tim Holloway wrote: is to construct an absolute URL.

    It may just be a terminology issue, but what you really want is a server-relative URL. You don't want to hard-code the protocol and host into the URL (which is what an absolute URL would entail) but rather, you want the URL to start with the context path of the web app. You can get that from the request using the expression language.
    2 months ago

    Cezar Apulchro wrote:Changed to JSP.

    But again, what is your intent for this page? There's no JSP-ness to it excepts the imports, of which none are referenced in the page body.

    And why swing imports?
    I assumed as there is no JSP-ness or JSF-ness to the code, that he's after pure HTML rather than XHTML, which, outside of JEE, is dead. ;-)

    And LOL, I totally glossed over the swing packages. Yeah, that's another head-scratcher.

    Remove the xmlns attribute from the <html> element and it will default to HTML5.

    And, why do you even have lines 1 through 11 in the file?

    And while it's not a problem to include line 12, it's superfluous.