Avatar billede fredand Forsker
08. marts 2010 - 10:57 Der er 4 kommentarer og
1 løsning

How to pass params to JSTL?

Hello Amigos!

I got an class extending from Struts Action class.

When an error occurs I try to show an jsp with an error message with JSTL:

<li><c:out value="${errorMess}"/></li>

In the Action I have tried to set errorMess like:

pRequest.setAttribute("errorMess", "ERROR MESSAGE");

pRequest.getSession().setAttribute("errorMess", "ERROR MESSAGE");

But when the jsp shows the li-tag is empty, like <li></li>.

It looks like I do not set the errorMess in the correct way?

If you see what I miss please let me know!

Best regards
Fredrik
Avatar billede fredand Forsker
08. marts 2010 - 12:38 #1
Hello!

Seems like I have to store the message like this:

pRequest.setAttribute("errorMess", "ERROR MESSAGE");

...and access it like:

<li><c:out value="${requestScope.errorMess}"/></li>


If you guys disagree, please let me know!

Best regards
Fredrik
Avatar billede arne_v Ekspert
09. marts 2010 - 00:54 #2
Any reason why you don't use the Struts error framework?

Like in:

ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("username.password.not.valid"));
saveErrors(request, errors);

and:

<html:errors/>

?
Avatar billede arne_v Ekspert
26. april 2010 - 03:35 #3
??
Avatar billede fredand Forsker
02. juli 2010 - 21:04 #4
Hello Arne!

You were right!

I do not understand how I could not get that to work.

(Please give svar)

Best
reagrsd
Avatar billede arne_v Ekspert
02. juli 2010 - 21:07 #5
.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester