File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Problem while creating Struts application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem while creating Struts application" Watch "Problem while creating Struts application" New topic
Author

Problem while creating Struts application

Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
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

Joined: Aug 03, 2008
Posts: 9321
    
  17

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)...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jun 08, 2008
Posts: 214
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

Joined: Sep 29, 2008
Posts: 12617

I wrote: Have you verified there is data in what you're passing to the JSP?
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
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

Joined: Aug 03, 2008
Posts: 9321
    
  17

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

Joined: Jun 08, 2008
Posts: 214
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

Joined: Aug 03, 2008
Posts: 9321
    
  17

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

Joined: Jun 08, 2008
Posts: 214
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

Joined: Jun 08, 2008
Posts: 214
Hi,

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




But Issue still persist.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem while creating Struts application