• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"Unterminated <c:out tag" Error

 
R Naijat
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
I have this piece of code in a JavaScript function #1, and try to call the charCounter() function from within #1. Receive the above error on the 5th line. Does anyone have any idea? any help is greatly appreciated.


 
R Naijat
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I received the error from within a JavaScript function, so thought its a JavaScript issue!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the charCounter() function? JavaScript?

If so, you can't mix JavaScript and JSP in this manner. Remember that JSPis evaluated on the server to format an HTML page to send to the browser. Once the browser has the HTML page, it evaluates the JavaScript in the page.

Please read this article to understand how JSP operates.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
R Naijat wrote:Sorry, I received the error from within a JavaScript function, so thought its a JavaScript issue!

<c:out> is JSP and has nothing to do with JavaScript as you will discover upon reading the article.
 
R Naijat
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
charCounter() is a JavaScript function which I posted below. The lines of code which give me the error, is within another JavaScript function. I'm trying to call charCounter() function from within the first JavaScript function.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the article. You are trying to mix JavaScript into JSP and that just can't happen.
 
R Naijat
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the original line which works properly. All I'm trying to do is to control the length of the filed, with the charCounter function instead of using the maxlength property. So I used <c:out b/c it was already being used and is working.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works because it understands that the JSP portions are evaluated and substituted on the server and simply inserted into the template to create a valid HTML page to send to the browser. You'll note that it does assume that the JSP and that the JavaScript will be evaluated at the same time and on the same machine.
 
R Naijat
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, I removed the c:out tags and tried to call the charCounter() function directly. Now I do not receive any error, but the portion of the page which is supposed to display the Title filed, does not do anything! Since its a JavaScript issue, I will create a topic in JavaScript postings.
 
R Naijat
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Btw, meanwhile am reading the article you mentioned, thanks!
 
R Naijat
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Per Bear I'm back to this topic again...

I removed the c:out tags and now I do not receive the original Unterminated tag error anymore. This is the part of code which I'm trying to control the Title filed with the charCounter() function. I receive this error:

The function charCounter must be used with a prefix when a default namespace is not specified.

Any idea?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At this point I have no idea what you are really trying to accomplish. Just removing the <c:out> tags isn't what I was talking about. The <c:out> tags were (I assume) there to provide server-side values to be injected into the markup at certain points. If you can just remove them, what was the point of their being there in the first place?

I'm still not convinced that you understand what JSP is and how it works.

So is the problem that:
  • The JSP isn't compiling because of syntax error in using the <c:out> tags?

  • Or is it that:
  • There are client-side errors after the HTML page is delivered to the browser?
  •  
    R Naijat
    Ranch Hand
    Posts: 40
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I already have a Title filed which is being controlled within a JavaScript function as follows and it works properly; the length of this filed is controlled by maxlength html property.

    Lets call this #1:



    This is what Im trying to accomplish:
    I need to get rid of this maxlenght html property and instead call the charCounter() function in order to let user know that how many chars he already entered and how many chars left. The charCounter() receives three fields: (field, count, max).

    Filed: the Title field
    Count: another field which let the user know how many chars left
    Max: the max number of chars allowed.

    So I tried to modify #1 - as following code - to call the charCounter() function. Also created the $left variable to send to charCounter() as count argument.

    And now I receive this error:

    The function charCounter must be used with a prefix when a default namespace is not specified




     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64178
    83
    IntelliJ IDE Java jQuery Mac Mac OS X
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It's still clear that you don't understand how a JSP template works. For example, you don't need to use JavaScript string concatenation.

    Let's say that that you had a JSP scoped variable named xyz that had the value "whatever" in it, and you wanted to embed it inside a JavaScript string. That should look like:


    Note that there is no + operator anywhere in sight!

    After the JSP executes, what gets sent to the browser as part of the response will be:


    The JSP <c:out> tag is substituted in place when the JSP executes.

    That should help simplify your markup considerably. What you have now is not only overly complex, but won't result in valid JavaScript syntax being generated.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic