开发者

How to call Java classes from JSP

开发者 https://www.devze.com 2023-01-03 04:19 出处:网络
I have two JSP files, one for getting the user input and the other开发者_JS百科 for printing the result.

I have two JSP files, one for getting the user input and the other开发者_JS百科 for printing the result. I have a class file called getdata.java. How should I access that class when the user inputs something and print the result in the result page?

/// getdata.java when user click button it redirect to result page..

<form action="Result.jsp" method="post">
<input type="text" name="textname" /><br></br>
<input type="submit" name="submit" value="Search"/> remove 

//// class file

public class On_Classes {

    public void  printData()
    {
        ....
    }

}

/// result page


Perhaps this might help? http://www.rgagnon.com/javadetails/java-0508.html Unless you wanted to link to the java page? If so upload the java class to the WEB-INF directory and then in the form action make it link to /servlet/classname?

Or if you wanted to retrieve form data: String resName = request.getParameter("formfieldname"); in the class.

0

精彩评论

暂无评论...
验证码 换一张
取 消