I have a problem...I'm stuck on jsp/bean manipulation. Details: ======= I am trying to read data sent from a bean and store it in the jsp page for use in immediate processing. I have been reading a lot of jsp sample codes on the sun site as well as Sam's teach yourself j2ee in 21 days and so far my assessment is that either I am being forced to use JSTLs most times or else what the samples are demonstrating is rudimentary. All I want to do is take data from a bean, store it to a variable declared within the scope of the jsp request or session. Could anyone give me a sample working code demonstrating data storage where data is being retrieved from a request/response combination into a JSP page declared variable?
My Non-working Code: =================== <jsp:useBean id="indexbean" scope="request" class="loginmodule.IndexBean" /> ... <jsp:setProperty name="IndexBean" property="*" /> <-- trying to get status of database query into variable Status --> <%! String Status= null;%> <% Status = ((String)request.getAttribute("STATUS")).getStatus(); -- "STATUS" is the String variable in the bean which stores the status if (Status != null) response.sendRedirect("http://localhost:8081/SOFTWARE/menu.html"); else response.sendRedirect("http://localhost:8081:/SOFTWARE/ErrorPg.html"); %> ... <-- Also tried using code: Status = mypackage.IndexBean.getSTATUS(); -->
Output: ====== I can not even get it to compile, but what happens is that if I sit there and click on the go button after three of four clicks it displays and then when I hit the form button, it says -- "An error occurred at line: 52 in the jsp file: /index.jsp Generated servlet error: The method getStatus() is undefined for the type String"
From the information you have provided I can guess you have class called loginmodule.IndexBean and it has method called getSTATUS() and this bean is stored in request scope with attribute named as STATUS,if this is correct then try the following