Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem while creating Struts application

 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new to Struts. I am plannig to create an Inventory application. As of now i have create two kind of functianlity add and display.
Here what my requirement is when appplication is loaded first page would be and Add product page will be display where user will be adding the details (product name, product price, product type and quantity), when user submit the form it should redirected to display page (productlist.jsp).

Below are Codes.

struts-config.xml



AddProductAction.java



ProductListAction.java




After i provide details about the product in the first page and after submitting page i'm not getting the (diplay of)productlist.jsp where i am able to see all the product present in the product table.

Could Anyone please help me what is going wrong here?
Please let me know if additional code(s) is / are required.

Thanks in Advance.

 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After i provide details about the product in the first page and after submitting page i'm not getting the (diplay of)productlist.jsp where i am able to see all the product present in the product table.

Then what are you actually able to see?? Is there an error/exception or the new record is not displayed?? Can you also show us the code of the ProductData class (on which you call the addProduct and getProducts methods)...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see the JSP you're using to display the products--that might be kind of important. Is there anything in the logs? Have you verified there is data in what you're passing to the JSP?

Please note that when pasting code in it's *extremely* helpful to limit it to only the code actually necessary to reproduce the problem. Things like Javadocs that are from the default IDE template, expository comments in config files, and so on--~50 lines of extraneous noise are demotivating.
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit / David,

Thanks for Reply.
When user submits the form he should be able to see all the products present in the product table. But here i am getting blank page. No errors / exceptions.

Following are codes for ProductData.java and productlist.jsp (This JSP is used to diplay all the products in the product table.

ProductData.java



productlist.jsp



Thanks in Advance.

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote: Have you verified there is data in what you're passing to the JSP?
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

Thanks for Reply.
There is a data in table. But Could you let me know how to verify that i being passed to JSP or not.

Thanks in Advance.
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the execute method of ProductListAction, iterate over the products list and display the values on the console (using System.out.println) or log the values. That will help you see if the products list actually has some values or not after you call ProductData.getProducts() ...
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit,

I decided to debug the application from scratch. So i did following changes in the struts-config file.



earlier it was <forward name="success" path="/ProductList.do" />. But now i changed to success.jsp which is as follows.

success.jsp



But still in vain i am not even getting success.jsp page after submitting values in Product JSP page.

I do not know what is the problem in this. Please help.

Thanks in Advance.
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay, your struts-cinfig.xml still has the result as /ProductList.do. Did you change your configuration to something like this??


Also did you check the server logs to see if there were any errors in execution of the action??

[Edit: Didn't see the configuration files properly]
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit,

Thanks for getting my attention for strut-config.xml i have changed it.

But i'm surprised that App Server log doesn't show about Inventory application. Below id the log for GlassFish Server. But application is running as it was running earlier, means there is no change in the behavior.

GlassFish Log



What is the next step that i have to do.

Thanks in Advance.
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Now i 'm getting only one line related to my application (/Inventory) in GlassFish Log. (bolded in below snippet)




But Issue still persist.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic