Scriptlet « Bean « JSP-Servlet Q&A

1. JSP: Scriptlet variables as EL bean?

To use scriptlet variables inside ${} I do:

  String myvar = "";
  pageContext.setAttribute("myvar", myvar);
Is that correct? Is there any way to it with out xxx.setAttribute and have myvar and ...

2. Use a UseBean id within a scriptlet

I have defined a bean using useBean and want to use it within a scriptlet to get a string value from a getter method. It gives me an error saying method getSilo() not found in test1.UserFormBean. I have defined the class UserFormBean as public and the method getSilo() as public. Here is my bean definition : package test1; import com.client.JspBean; public ...

3. Binding scriptlet variable with jsp:useBean

Hi, currently I maintain a project which makes heavy(!) use of scriptlets in its JSPs. There is one things that bugs me most. Each pages includes a default.jsp, this default JSP contains a scriptlet that creates a Context object ctx which offers access to the user, his roles etc. In the specific pages this often results in something like: ... <% ...