You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dirk Behrendt <sc...@web.de> on 2003/07/24 13:45:07 UTC
Replace scriptlet in a JSP page
Hello!
I have read the discussion about tag libs.
No logic should be in a JSP page to fullfill the MVC concept. But I dont
know how to replace the following scriptlet in my JSP.
<%SetUpLanguages l = new SetUpLanguages(request);%>
It is absolutely necessary form e application.
Thank you!
Dirk
Re: Replace scriptlet in a JSP page
Posted by Carl Walker <wa...@georgetown.edu>.
Can you rewrite SetUpLanguages to take an empty constructor? If you can,
then you can use jsp:setProperty to take what you need from the request
object and put it in a Java Bean.
SetUpLanguages.java
---
package myclasses;
public class SetUpLanguages implements java.io.Serializable
{
public SetUpLanguages() {}
private String contentLanguage;
public String getContentLanguage() {
return contentLanguage;
}
public void setContentLanguage(String _contentLanguage) {
contentLanguage = _contentLanguage;
}
}
the JSP
---
<jsp:useBean id="setUpLanguages"
class="myclasses.SetUpLanguages"
scope="session" />
<jsp:setProperty name="setUpLanaguages" property="contentLanguage"
value='<%= request.getHeader("Content-language"); %>' />
Dirk Behrendt wrote:
> Hello!
>
> I have read the discussion about tag libs.
>
> No logic should be in a JSP page to fullfill the MVC concept. But I dont
> know how to replace the following scriptlet in my JSP.
>
> <%SetUpLanguages l = new SetUpLanguages(request);%>
>
> It is absolutely necessary form e application.
>
> Thank you!
>
> Dirk
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org