Using NetWeaver to develop web modules

Source: Internet
Author: User
Prerequisite

The Window®open PERSPECTIVE®OTHER®J2EE perspective is Open. creating the Web Module Project

The Web resources are developed in a Web Project in the Java perspective.

...

1. Choose File®new®project from the main menu.

2. Choose web®dynamic Web Project 2.5 on the NEW Project screen.

3. Choose Next to proceed to the "Create a Dynamic Web 2.5 Project screen."

4. Enter Converterweb in the Project Name field.

5. To assign the WEB project to the previously created Enterprise application project, check ADD project to a EAR an D Select Converterear from the EAR Project Name field.

6. Choose Finish to create your Web ' s project structure. creating a Web Client

The WEB client in this tutorial is a JSP.

...

1. In the Project Explorer choose Converterweb®webcontent.

2. From the context menu of webcontent choose New®other.

3. On the New screen choose Web®jsp.

4. Choose Next.

5. Enter index.jsp in the File Name field.

6. Choose Finish.

7. Implement the JSP as follows:

<%@ page import= "com.sap.tutorial.javaee.ConverterLocal,

java.math.*, javax.naming.* "%>

<%!

Private converterlocal Converterbean = null;

Public void Jspinit () {

Try {

InitialContext IC = new initialcontext ();

Converterbean = (converterlocal)

Ic.lookup ("Java:comp/env/converter");

catch (Exception ex) {

System.out.println ("couldn ' t create converter bean.") +

Ex.getmessage ());

}

}

Public void Jspdestroy () {

Converterbean = null;

}

%>

<title>currency converter</title>

<body>

<p>enter an amount to convert:</p>

<form method= "Get" >

<input type= "text" name= "Amount" size= ">"

<input type= "Submit" value= "Submit" >

</form>

<%

String amount = Request.getparameter ("Amount");

if (Amount!= null && amount.length () > 0) {

BigDecimal value = new BigDecimal (amount);

BigDecimal Euroamount = Converterbean.dollartoeuro (value);

%>

<p>

<%= amount%> USD are <%= euroamount%> EUR

<br>

<%

BigDecimal Dollaramount =

Converterbean.eurotodollar (value);

%>

<%= amount%> EUR are <%= dollaramount%> USD

</p>

<%

}

%>

</body>

8. Save the index.jsp file. Editing The Web.xml deployment descriptor

...

1. Expand the Web-inf folder under WebContent.

2. Double-click on the Web.xml file to open it for editing.

3. Add the following code in the XML source to define a local EJB reference to Converter Bean:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.