JoseAntonio1984
JoseAntonio1984

Reputation: 191

Create table in JSP with Struts2 and MySQL database

I would like that someone explain me how can I call the action that recovers the info of the DBs directly on the JSP page where I want show the table data.

The JSP page must charge the table data directly on first execution.

Upvotes: 1

Views: 1231

Answers (2)

JoseAntonio1984
JoseAntonio1984

Reputation: 191

For execute an action directly from jsp:

<s:action name="fooAction"></s:action>

In struts.xml you must write:

<package name="default" extends="struts-default" namespace="/">         
    <action name="fooAction" class="com.es.action.FooAction">
        <result name="success">ok.jsp</result>
        <result name="error">ko.jsp</result>            
    </action>
</package>

Now i will follow your indications and i'll try to use display tag to show data into the Grid. Thanks for your answer.

Upvotes: 0

Jwalin Shah
Jwalin Shah

Reputation: 2521

Following steps you need to follow.

1) You need to write a method which return your table data into the vector/arraylist.

2) That Action needs to be mapped with JSP into the struts.xml file.

3) Now, you need to tag to access vector/arraylist which is defined into action. and you will get that table data into your jsp page.

4) you can use display tag(need to include lib file) to show data into the Grid.

Upvotes: 1

Related Questions