Re: error with if condition

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Friday, June 26, 2009, 1:33:34 PM, far4ever wrote:
>
> hi,
>  am using FreeMarker with spring 
> in the login page i have a code spinet as follows..
>
> <#if Parameters.login_error?? >
>         Your login attempt was not successful, try again.<br/><br/>
>             Reason:
>          ${Parameters.login_error}
>     </#if>
> .. 
> where i want the error message on login failure to be printed

Looks OK so far.

> but on the browser what i get is as follows
> ........
> <#if Parameters.login_error?? > Your login attempt was not successful, try
> again.
>
> Reason: ${Parameters.login_error} 

Umm... you get that in the *browser*? The browser should never ever
receive FreeMarker tags and interpolations, as those should be
resolved on the server.

> ......
>  where the if condition is not being interpreted properly.
> and i tried as :
> <#if Parameters.login_error?exists>
>
> in both the case the condition gets printed as it is there in the ftl page
> but with out the closing tag of the if close.
> other content in the page is being shown properly and also the functionality
> (login function) is also working
>
> can anyone help me 2 figure out what has gone wrong..

If the output indeed contains ${...} stuff, then the templates are not
processed by FreeMarker at all, but are served like static files. That
means, there is something wrong with the your HTTP server or
Servelet-related setup. What URL do you enter into the browser? You
shouldn't ever visit .ftl-s directly, as they need something that
prepares the data-model, this being an MVC template engine. If you are
using JSP-Model-2-like setup, please see:
http://freemarker.org/docs/pgui_misc_servlet.html

> thanks in advance.

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.