Developing web modules using NetWeaver
cjKing 2021-08-07 15:28:01


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 J2EE 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 an EAR and 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=",

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



  private ConverterLocal converterBean = null;

  public void jspInit() {

    try {

     InitialContext ic = new InitialContext();

     converterBean = (ConverterLocal)


    } catch (Exception ex) {

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





 public void jspDestroy() {

  converterBean = null;






<title>Currency Converter</title>




<h1> Currency Converter</h1>


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

<form method="get">

<input type="text" name="amount" size="20">

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



  String amount = request.getParameter("amount");

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

  BigDecimal value = new BigDecimal(amount);

  BigDecimal euroAmount = converterBean.dollarToEuro(value);




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



  BigDecimal dollarAmount =



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







       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:






       4.      To save the file, choose File  Save from the main menu.

Configuring the Project References

Since your Web project uses resources from the ConverterEJB project, you have to set these references:


       1.      Select ConverterWEB in the Project Explorer.

       2.      From the context menu choose Properties.

       3.      On the Properties of ConverterWEB screen choose Java Build Path Projects.

       4.      Choose Add.

       5.      Select ConverterEJB.

       6.      Choose OK.

       7.      Choose Project References.

       8.      On the Setting Java Build Path screen that pops up, choose Apply.

       9.      Select the ConverterEAR and ConverterEJB projects.

   10.      Choose OK.


You have successfully created the Web module of the Converter Application. 

Please bring the original link to reprint ,thank
Similar articles