Hi i am having small requirement like i have to connect to db from db i have
select ted the emp table from there i need to show that result in my
jsp.ihave written java code like this below in action .here i am not
able to knw
how to proceed from here
can u help me here
*
public* *class* DbConnect {
String result=*null*,SUCCESS;
*public* String execute()
{
*try*{
Connection con;
Class.*forName*("oracle.jdbc.driver.OracleDriver").newInstance();
con=DriverManager.*getConnection*("jdbc:oracle:thin:@192.168.0.186
:1521:earchive","scott","tiger");
Statement stmt=con.createStatement();
ResultSet rs = stmt.executeQuery("select * from emp");
*if*(rs.next())
{
System.*out*.println(rs.getString(1));
System.*out*.println(rs.getString(2));
System.*out*.println(rs.getString(3));
System.*out*.println(rs.getString(4));
result=SUCCESS;
*return* result;
}
// RequestDispatcher
requestDispatcher=getServletContext().getRequestDispatcher("/test.jsp");
//requestDispatcher.forward(request,response);
}
*catch*(Exception e){
e.printStackTrace();
}
*return* result;
On 11/16/07, Thilo Ettelt <[EMAIL PROTECTED]> wrote:
>
> sure, in your action method you can define:
>
> ValueStack stack = ActionContext.getContext().getValueStack();
>
> and then fill whatever object you have into the valuestack:
>
> String sample = "Hello World";
> stack.set("myIdentifier", sample);
>
> In your JSP you can use the s:property tag to display your String in
> this case:
>
> <s:property value="myIdentifier"/>
>
> you can put any ognl expression into the value part, read the docs for
> more info on ognl.
> for example you could have put an array onto the stack and call the
> object at index 5 by using:
>
> <s:property value="myIdentifierArray[5]"/>
>
> You can also call methods like this method of a String object:
>
> <s:property value="myIdentifier.toLowerCase"/>
>
>
> - Thilo
>
> vijay vijay wrote:
> > Hi can u give me some sample code to me
> >
> > On 11/16/07, Thilo Ettelt <[EMAIL PROTECTED]> wrote:
> >
> >> Access the ValueStack in your action, it allows you to store objects
> and
> >> you can retrieve them from your jsp. You might need to know about the
> >> ActionContext object accessable from your action.
> >>
> >> Read more from the docs :)
> >>
> >>
> >> - Thilo
> >>
> >> vijay vijay wrote:
> >>
> >>> Hi
> >>> i am writting a database connectionin action, here i wanted to
> >>>
> >> put
> >>
> >>> tth result back in to a jsp page.
> >>> in jsp what i need to write
> >>>
> >>> any one help me here
> >>>
> >>>
> >>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>