• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javax.servlet.ServletException:javax.servlet.jsp.JspException: Cannot find bean: "riga" in any scope

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, i'm trying to solve this problem in delevoping my application but i still have found the solution:

Here 's struts-config.xml action mapping:
<action-mappings>
<action name="LoginForm" path="/login" scope="session" type="com.myapp.struts.LoginAction" validate="false">
<forward name="success" path="/success.jsp"/>
<forward name="failure" path="/login.jsp"/>
</action>
<action name="SuccessForm" path="/success" scope="request" type="com.myapp.struts.SuccessAction" validate="false">
<forward name="dettaglio" path="/dettail.jsp"/>
<forward name="errore" path="/login.jsp"/>
<forward name="recapiti" path="/recap.jsp"/>
</action>
<action path="/Welcome" forward="/welcomeStruts.jsp"/>
</action-mappings>

the forward page dettail.jsp is ok here's the code:
<logic:greaterThan name="size" value="0">
<table width="90%" border="1" cellpadding="2" cellspacing="2">
<tr><td align="center" colspan="5">Recapiti locale</td></tr>
<tr><td align="center" colspan="5">
<logic:iterate property ="lines_recapiti" name="SuccessForm" id="riga" >
<tr>
<td align="right"><bean:write name="riga" property="codiceProc" /></td>
<td align="right"><bean:write name="riga" property="descProc" /></td>
<td align="right"><bean:write name="riga" property="impAvere"/> </td>
<td align="right"><bean:write name="riga" property="impDare" /></td>
<td align="right"><bean:write name="riga" property="impDiff" /></td>
</tr>
</logic:iterate>

</logic:greaterThan>
but the other forward page named recap.jsp having same iteration :
<logic:iterate property ="lines_recapiti" name="SuccessForm" id="riga" >
<tr>
<logic:present name ="riga">
<td align="right"><bean:write name="riga" property="codiceProc" /></td>
<td align="right"><bean:write name="riga" property="descProc" /></td>
<td align="right"><bean:write name="riga" property="impAvere"/> </td>
<td align="right"><bean:write name="riga" property="impDare" /></td>
<td align="right"><bean:write name="riga" property="impDiff" /></td>
</logic:present>
<logic:notpresent name="riga"> DON'T FIND ANY ROWWWW</logic:notpresent>

give me the error:
javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean: "riga" in any scope

Here is java code in SuccessAction for put data retrived from DB into ArrayList named riga

SuccessForm formBean = (SuccessForm) form;
.......
" int k = riga.size();
totAvere+=obj2.totAvere;
totDare+=obj2.totDare;
totSaldo+=obj2.totSaldo;
formBean.setLines_recapiti(riga);
logger.info("riga caricata:");

logger.info(k);"

and here is formBean property:


public class SuccessForm extends org.apache.struts.action.ActionForm {

private String gruppo;
private String stato ;
private String Ciclo;

private List lines = null;
private List lines_recapiti = null;


public List getLines_recapiti() {
return lines_recapiti;
}
public void setLines_recapiti(List lines_recapiti) {
this.lines_recapiti = lines_recapiti;
}

cheking on log : riga size is equal to 1 ( I've found 1 row on DB) it seems correct the list is not empty

but when i try to forward jsp page recap.jsp i have the error:
org.apache.jasper.JasperException: An exception occurred processing JSP page /recap.jsp at line 33

30: <logic:iterate property ="lines_recapiti" name="SuccessForm" id="riga" >
31: <tr>
32: <logic:present name ="riga">
33: <td align="right"><bean:write name="riga" property="codiceProc" /></td>
34: <td align="right"><bean:write name="riga" property="descProc" /></td>
35: <td align="right"><bean:write name="riga" property="impAvere"/> </td>
36: <td align="right"><bean:write name="riga" property="impDare" /></td>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean: "riga" in any scope
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)


Any help will be appreciate because i loose 2 day trying to solve this problem and headache is incoming.
Thanks in advance
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So where do you put the bean into scope?
 
corrado martini
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

DavidT Newton wrote:So where do you put the bean into scope?


DavidT Newton wrote:So where do you put the bean into scope?


Thanks David for your reply, now i'll use the code tag. I hope this will help you to understand my problem
this is my struts-config.xml file:

And this is the jsp page that cause the problem:



The tag
is ok because the string "MANCA LA RIGAAAA..." is not displayed


but when I try to show the ArrayList's elements lines_recapiti using

it seems that bean named "riga" doesn't exist but I used the same method in another jsp page and in this case everything is ok..

Hope you understand

Here it's 08:48 AM. It's a warm sunny day maybe you are :sleep: I'll wait

Many thanks
 
corrado martini
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I must add that I'm using struts 1.2.9 embedded in my Netbeans 6.5.
Does anyone think it' s better change struts libraries to struts 2 ?

I don't know where is the bug , other variables in the same form are ok.

for example here is the variables in SuccessForm


the Getters and Setters methods are automatically generated with <alt><ins> buttons

In the action form SuccessAction.java I have this code.


and this is the jsp page:

At run time i see that riga.size is 2 ( Ok there are 2 rows retrived)
Well i have the same error:
Cannot find bean: "riga" in any scope , but if I remove code used for display property lines recapiti I see variable stato correctly displayed
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

corrado martini wrote:I must add that I'm using struts 1.2.9 embedded in my Netbeans 6.5.
Does anyone think it' s better change struts libraries to struts 2 ?


That would require a complete rewrite.
 
corrado martini
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok , so you think it's better mantain this Struts version and try to solve the problem...
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well yeah, if you're already done--but I wouldn't have developed a new app in Struts 1 anyway. But I'd also use JSTL instead of Struts tags when functionality overlaps, like the documentation suggests (or at least it used to, haven't looked at S1 in some time).

If you say the same code works elsewhere, using the same form and the same JSP, then something else is funky. Try creating a minimal use case that demonstrates the failure and see what happens.
 
corrado martini
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally I solved!!!
Thanks David
But the bad news: I don't find the bug. And I don't like this.. As you told me I changed everything in struts Action form and i realize the problem was not here.
so, after doing a backup of save all recapiti.jsp page ( the page that give me the error).

I replace all code of dettaglio.jsp page ( the page where the list is correctly displayed) into the wrong page. And it's going fine!!!1

And so I don't know where is the error?
here is the right page:

The red code is in common with wrong page. And this is the code of wrong page


And this is struts-config.xml


As you probably know i'm not experiened in java struts ( I'm an old Cobol IBM mainframe programmer with some ackoledgements in C language... ).
and so I waste a lot of time in searching the bug in studying tons of documentation about java beans and struts.

Anyway many thanks .
 
corrado martini
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!.
I found the error. the problem is in the object who represents the row to display.

the list lines_recapiti is the Collection in jsp page:


It' seems everything is correct but beans named "riga" needs getter & setter!!
so here's the correct object that receive every row:

Good work to everybody
 
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic