JSP page access regular Java class (non-Java bean)

M

Matt

I am new to JSP. But most of the time people say JSP page access Java
Bean classes.
I want to know what if I want to access regular Java classes?? Should
I do like this
in the code:
<%
NormalJavaClass cl = new NormalJavaClass();
cl.process();
%>

<%-- JSP page access Java Bean -- %>
<jsp:useBean scope="session" id="formDataBeanObj"
class="formdatatest.FormDataBean"/>
<jsp:setProperty name="formDataBeanObj" property="*"/>

<HTML>
<HEAD>
<TITLE>page1.jsp</TITLE>
<BODY>
<FORM METHOD="POST" ACTION="page2.jsp">
<H2>User Name = <jsp:getProperty name="formDataBeanObj"
property="username"/></H2>
<%
NormalJavaClass cl = new NormalJavaClass();
cl.process();
%>

<P><INPUT TYPE="SUBMIT" VALUE="submit here">
</FORM>
</BODY>
</HTML>


Please advise. Thanks!!
 
K

KC Wong

I am new to JSP. But most of the time people say JSP page access Java
Bean classes.
I want to know what if I want to access regular Java classes??

Import the class with a <%@ page import="com.yourcompany.yourclass" %> tag,
and put your class in the server's classpath (usually context\WEB-INF\lib).
Then use it just like you use the core classes.


KC
 
T

Troy Kinsella

KC said:
Import the class with a <%@ page import="com.yourcompany.yourclass" %> tag,
and put your class in the server's classpath (usually context\WEB-INF\lib).
Then use it just like you use the core classes.


KC

WEB-INF\lib is for jars, WEB-INF\classes is for classes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top