JBuilder9.0+Weblogic7.0ʵսƪ֮JSP+SERVLETƪ

Java 0 ۣ0 Ƽ

JBuilder9+Weblogic7ʵսƪ

JSP + SERVLETƪ

                                                                             ߣ          

E_mailhk_sz@163.com

   

һƪ JSP + SERVLET

 

һJBuilder

1.JBuilder ʼ//Borland JBuilder 9 Enterprise Trial/Borland JBuilder 9 Enterprise Trial

2.ʱڳ֣Closeرգһֻڵһε¼ʱ֣

 

һ

1.ڲ˵ѡFile/New Project ... һ¹̣

2.NameMathSample

3.Next

4.NextĬѡ

5.Finish

 

Web Application

1.ڲ˵ѡFile/New...Object Galleryڣ

2.Webҳ

3.ѡWeb ApplicationȻOKWeb Applicationڣ

4.NameMathSample

5.ȷDirectoryҲMathSample

6.еĬѡ

7.OKweb application attributesweb application directoryɹ⣬web.xmlļڹ̴еMathSample/Deployment descriptorsĿ¼¡web.xmlļweb applicationļthe context pathservletsclassesϢÿһclassapplicationJBuilderԶ

 

ġ JSPs

JavaServer PagesһӦJ2EEıʾ㡣ڱǽһJSPʾHTML pageԼJ2EEһservletͨšJSPļHTMLjava scriptlets

1.ڲ˵ѡFile/New...Object Galleryڣ

2.Webҳ

3.ѡJavaServer PageȻOKJSPڣ

4.NameNumbersPage

5. Generate sample beanѡ

6. ѡGenerate Error page

7.Next

8.ȷGenerate submit formѡУ

9.Next

10.ٵNext

11NumbersPage_error.jspNext

12.FinishұߵѾԿJSP pagesڹ̴չMathSample/Root directoryԿNumbersPage.jspNumbersPage_error.jspǶ

13.ѡĵڵϷNumbersPageҳ޸еĴ룺

<%@ page errorPage="NumbersPage_error.jsp"%>

滻Ϊ

<%@ page errorPage="NumbersPage_error.jsp" import="java.util.Calendar"%>

JBuilder Generated JSP

滻Ϊ

The time is <%= Calendar.getInstance().getTime() %><br><br>

Enter numbers:

form method="post"

滻Ϊ

form action="controller" method="post"

<br><br>

滻Ϊ

<strong>First Number: <input type="text" name="num1" value=""></strong>

<br><br>

<strong>Second Number: <input type="text" name="num2" value=""></strong>

<br><br>

14.ڲ˵ѡFile/Save All޸ġ

 

塢 Servlets

ڣһ򵥵ServletServletsһextend the HTTPServlet APIjava classesdzCGI scripts㽫ֵøɫڱƪУservlet servesΪcontrollerռJSP벢ڼHTML pageʽʾС

1.ڲ˵ѡFile/New... Object Galleryڣ

2.Webҳ

3.ѡServletȻOKServletڣ

4.ClassController򵼽һmathsampleΪControllerclassNext

5.ѡdoGet()ѡdoPost()

6.ѡеĻѡGenerate SHTMLĬDzѡ

7.Next

8.Next

9.Step 4 of 5ʾservletweb.xmlļеϸϢ

10.Finishservlet codeԶɡ

11. ѡĵڵϷControllerҳ޸doPost methodĴ룺

PrintWriter out = response.getWriter();

֮ӣ

int num1 = Integer.parseInt(request.getParameter("num1"));

int num2 = Integer.parseInt(request.getParameter("num2"));

int result = num1 + num2;

out.println("<p>The servlet has received a POST. This is the reply.</p>");

滻Ϊ

out.println("<p>"+num1+" + "+num2+" = "+ result + "</p>");

12.ڲ˵ѡProject/Rebuild Controller.javaִУҲֱڹ̴ѡController.javaҼѡRebuildִСûбĻ㽫DIE·ϢпBuild SuccessfulϢ

Ѿweb applicationˡܿȷĽôˡ

   

ҵ׷ţ̳www.newer.com.cn/bbsͳԱ̳www.csdn.netӭתأ뱣Լ޶ߵ֣лл

ĵַhttp://com.8s8s.com/it/it17287.htm