Showing posts with label webshpere. Show all posts
Showing posts with label webshpere. Show all posts

Wednesday, March 13, 2013

comment_icon 0 Web.XML Explained


The web.xml Deployment Descriptor file tell about that how application will be deployed in the server or servlet container such as TOMCAT
This file is Required for every application which will be deployed on Tomcat/Apache . The location of Web.XML is always Application-root/WEB-INF/web.xml or WebContent/WEB-INF/web.xml

There is minimum one tag is required in web.xml that is  <web-app> TAG. This  contains following information
 <?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
     version="2.5">
</web-app>

WEB-APP CAN CONTAIN VARIOUS DIFFERENT ELEMNETS. A complete web-app example is given below please click the TAG for more details

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">

        <!-- ========================================================== -->
        <!-- General -->
        <!-- ========================================================== -->

        <!-- Name the application -->
        <display-name>Example App</display-name>
        <description>An example application which is used to play with some of the features of Tomcat</description>

        <!-- This app is cluster-ready -->
        <distributable />

        <!-- Set timeout to 120 minutes -->
        <session-config>
                <session-timeout>120</session-timeout>
        </session-config>


        <!-- ========================================================== -->
        <!-- Custom Tag Libraries -->
        <!-- ========================================================== -->

        <!-- Taglib declarations are no longer required since JSP 2.0, see Removing taglib from web.xml -->
        <!-- The <taglib> did not need to be a child of <jsp-config> in earlier versions but is required as of Tomcat 7 -->
        <!-- Note that you can only have one <jsp-config> element per web.xml -->
        <!--
        <jsp-config>
                <taglib>
                        <taglib-uri>mytags</taglib-uri>
                        <taglib-location>/WEB-INF/jsp/mytaglib.tld</taglib-location>
                </taglib>
        </jsp-config>
        -->


        <!-- ========================================================== -->
        <!-- JSP Configuration -->
        <!-- ========================================================== -->

        <jsp-config>
                <jsp-property-group>
                        <url-pattern>*.jsp</url-pattern>
                        <include-prelude>/WEB-INF/jspf/prelude1.jspf</include-prelude>
                        <include-coda>/WEB-INF/jspf/coda1.jspf</include-coda>
                </jsp-property-group>
        </jsp-config>


        <!-- ========================================================== -->
        <!-- Context Parameters -->
        <!-- ========================================================== -->

        <context-param>
                <description>Enable debugging for the application</description>
                <param-name>debug</param-name>
                <param-value>true</param-value>
        </context-param>
        <context-param>
                <description>The email address of the administrator, used to send error reports.</description>
                <param-name>webmaster</param-name>
                <param-value>address@somedomain.com</param-value>
        </context-param>


        <!-- ========================================================== -->
        <!-- JNDI Environment Variables -->
        <!-- ========================================================== -->

        <env-entry>
                <env-entry-name>webmasterName</env-entry-name>
                <env-entry-value>Ms. W. Master</env-entry-value>
                <env-entry-type>java.lang.String</env-entry-type>
        </env-entry>
        <env-entry>
                <env-entry-name>cms/defaultUserSettings/recordsPerPage</env-entry-name>
                <env-entry-value>30</env-entry-value>
                <env-entry-type>java.lang.Integer</env-entry-type>
        </env-entry>
        <env-entry>
                <env-entry-name>cms/enableXMLExport</env-entry-name>
                <env-entry-value>false</env-entry-value>
                <env-entry-type>java.lang.Boolean</env-entry-type>
        </env-entry>
        <env-entry>
                <env-entry-name>cms/enableEmailNotifications</env-entry-name>
                <env-entry-value>true</env-entry-value>
                <env-entry-type>java.lang.Boolean</env-entry-type>
        </env-entry>


        <!-- ========================================================== -->
        <!-- Servlets -->
        <!-- ========================================================== -->

        <!-- Simple Servlet, provide a name, class, description and map to URL /servlet/SimpleServlet -->
        <servlet>
                <servlet-name>Simple</servlet-name>
                <servlet-class>SimpleServlet</servlet-class>
                <description>This is a simple Hello World servlet</description>
        </servlet>
        <servlet-mapping>
                <servlet-name>Simple</servlet-name>
                <url-pattern>/servlet/SimpleServlet</url-pattern>
        </servlet-mapping>

        <!-- CMS Servlet, responds to *.cms URL's -->
        <servlet>
                <!-- Identification -->
                <servlet-name>cms</servlet-name>
                <servlet-class>com.metawerx.servlets.ContentManagementSystem</servlet-class>
                <description>This servlet handles requests for the CMS (it is a controller in an MVC architecture)</description>

                <!-- This servlet has two parameters -->
                <init-param>
                        <param-name>debug</param-name>
                        <param-value>true</param-value>
                </init-param>
                <init-param>
                        <param-name>detail</param-name>
                        <param-value>2</param-value>
                </init-param>

                <!-- Load this servlet when the application starts (call the init() method of the servlet) -->
                <load-on-startup>5</load-on-startup>
                <!-- <run-at>0:00, 6:00, 12:00, 18:00</run-at> This tag is only valid for Resin -->
        </servlet>

        <!-- Map some URLs to the cms servlet (demonstrates *.extension mapping) -->
        <servlet-mapping>
                <!-- For any URL ending in .cms, the cms servlet will be called -->
                <servlet-name>cms</servlet-name>
                <url-pattern>*.cms</url-pattern>
        </servlet-mapping>

        <!-- Rewriter Servlet, responds to /content/* and /admin/RewriterStatistics URL's -->
        <!-- Define a servlet to respond to /content/* URL's -->
        <servlet>
                <servlet-name>rewriter</servlet-name>
                <servlet-class>com.metawerx.servlets.URLRewriter</servlet-class>
        </servlet>

        <!-- Map some URL's to the rewriter servlet (demonstrates /path/* and specific URL mapping) -->
        <servlet-mapping>
                <!-- For any URL starting with /content/, the rewriter servlet will be called -->
                <servlet-name>rewriter</servlet-name>
                <url-pattern>/content/*</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
                <!-- The rewriter servlet can also be called directly as /admin/RewriterStatistics, to return stats -->
                <servlet-name>rewriter</servlet-name>
                <url-pattern>/admin/RewriterStatistics</url-pattern>
        </servlet-mapping>

        <!-- PathJSP Servlet, maps /shop/item/* URL's to a JSP file -->
        <!-- Define a JSP file to respond to /shop/item/* URL's -->
        <servlet>
                <servlet-name>pathjsp</servlet-name>
                <jsp-file>pathfinder.jsp</jsp-file>
        </servlet>

        <!-- Map some URL's to the pathjsp servlet (demonstrates /long/path/* URL mapping) -->
        <servlet-mapping>
                <!-- For any URL starting with /shop/item/, the pathjsp servlet will be called -->
                <servlet-name>pathjsp</servlet-name>
                <url-pattern>/shop/item/*</url-pattern>
        </servlet-mapping>


        <!-- ========================================================== -->
        <!-- Filters -->
        <!-- ========================================================== -->

        <!-- Example filter to set character encoding on each request (from Tomcat servlets-examples context) -->
        <filter>
                <filter-name>Set Character Encoding</filter-name>
                <filter-class>filters.SetCharacterEncodingFilter</filter-class>
                <init-param>
                        <param-name>encoding</param-name>
                        <param-value>EUC_JP</param-value>
                </init-param>
        </filter>
        <filter-mapping>
                <filter-name>Set Character Encoding</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

        <!-- Example filter to dump the HTTP request at the top of each page (from Tomcat servlets-examples context) -->
        <filter>
                <filter-name>Request Dumper Filter</filter-name>
                <filter-class>filters.RequestDumperFilter</filter-class>
        </filter>
        <filter-mapping>
                <filter-name>Request Dumper Filter</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>


        <!-- ========================================================== -->
        <!-- Listeners -->
        <!-- ========================================================== -->

        <!-- Define example application events listeners -->
        <listener>
                <listener-class>com.metawerx.listener.ContextListener</listener-class>
        </listener>
        <listener>
                <listener-class>com.metawerx.listener.SessionListener</listener-class>
        </listener>


        <!-- ========================================================== -->
        <!-- Security -->
        <!-- ========================================================== -->

        <!-- Define roles -->
        <security-role>
                <role-name>admin</role-name>
        </security-role>
        <security-role>
                <role-name>cms_editors</role-name>
        </security-role>
        
        <!-- Define a constraint to restrict access to /private/* -->
        <security-constraint>

                <display-name>Security constraint for the /private folder</display-name>

                <web-resource-collection>
                        
                        <web-resource-name>Protected Area</web-resource-name>
                        <url-pattern>/private/*</url-pattern>
                        
                        <!-- If you list http methods, only those methods are protected. -->
                        <!-- Leave this commented out to protect all access -->
                        <!--
                        <http-method>DELETE</http-method>
                        <http-method>GET</http-method>
                        <http-method>POST</http-method>
                        <http-method>PUT</http-method>
                        -->

                </web-resource-collection>

                <auth-constraint>
                        <!-- Only only administrator and CMS editors to access this area -->
                        <role-name>admin</role-name>
                        <role-name>cms_editors</role-name>
                </auth-constraint>

        </security-constraint>

        <!-- FORM based authentication -->
        <!-- Leave this commented out, we will use BASIC (HTTP) authentication instead -->
        <!--
        <login-config>
                <auth-method>FORM</auth-method>
                <form-login-config>
                        <form-login-page>/login.jsp</form-login-page>
                        <form-error-page>/error.jsp</form-error-page>
                </form-login-config>
        </login-config>
        -->
        <!-- This application uses BASIC authentication -->
        <login-config>
                <auth-method>BASIC</auth-method>
                <realm-name>Editor Login</realm-name>
        </login-config>

        <!-- Define a constraint to force SSL on all pages in the application -->
        <security-constraint>

                <web-resource-collection>
                        <web-resource-name>Entire Application</web-resource-name>
                        <url-pattern>/*</url-pattern>
                </web-resource-collection>

                <user-data-constraint>
                        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
                </user-data-constraint>

        </security-constraint>


        <!-- ========================================================== -->
        <!-- Error Handler -->
        <!-- ========================================================== -->

        <!-- Define an error handler for 404 pages -->
        <error-page>
                <error-code>404</error-code>
                <location>/error404.jsp</location>
        </error-page>

        <!-- Define an error handler for java.lang.Throwable -->
        <error-page>
                <exception-type>java.lang.Throwable</exception-type>
                <location>/errorThrowable.jsp</location>
        </error-page>


        <!-- ========================================================== -->
        <!-- Extra MIME types -->
        <!-- ========================================================== -->

        <!-- Set XML mime-mapping so spreadsheets open properly instead of being sent as an octet/stream -->
        <mime-mapping>
                <extension>xls</extension>
                <mime-type>application/vnd.ms-excel</mime-type>
        </mime-mapping>


        <!-- ========================================================== -->
        <!-- Locale -->
        <!-- ========================================================== -->

        <!-- Set Locale Encoding -->
        <locale-encoding-mapping-list>
                <locale-encoding-mapping>
                        <locale>ja</locale>
                        <encoding>Shift_JIS</encoding>
                </locale-encoding-mapping>
        </locale-encoding-mapping-list>


        <!-- ========================================================== -->
        <!-- Welcome Files -->
        <!-- ========================================================== -->

        <!-- Define, in order of preference, which file to show when no filename is defined in the path -->
        <!-- eg: when user goes to http://yoursite.com/ or http://yoursite.com/somefolder -->
        <!-- Defaults are provided in the server-wide web.xml file, such as index.jsp, index.htm -->
        <!-- Note: using this tag overrides the defaults, so don't forget to add them here -->
        <welcome-file-list>
                <!-- Use index.swf if present, or splash.jsp, otherwise just look for the normal defaults -->
                <welcome-file>index.swf</welcome-file>
                <welcome-file>splash.jsp</welcome-file>
                <welcome-file>index.html</welcome-file>
                <welcome-file>index.htm</welcome-file>
                <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>

</web-app>

Sunday, February 26, 2012

comment_icon 5 Sending E-Mail via G-mail using Java


package mymail;



import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class Mymail   {
 
 
 public Mymail(){
  super();
 }


/*REMOVE THIS TO TEST AS JAVA APPLICATION 

public static void main(String args[]) throws AddressException, MessagingException{
  Mymail m =new Mymail();
  m.GmailSend("coolasr@gmail.com", "hello", "hello");
 }*/


public boolean GmailSend  (String to,String subject,String messageText) throws AddressException, MessagingException{
  
String host="smtp.gmail.com", user="YOUE USERNAME", pass="YOUR PASSWORD";

      
String SSL_FACTORY ="javax.net.ssl.SSLSocketFactory";       
boolean sessionDebug = true;
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol.", "smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.fallback", "false");
props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
Session mailSession = Session.getDefaultInstance(props,null);
mailSession.setDebug(sessionDebug);
Message msg =new MimeMessage(mailSession);
//msg.setFrom(new InternetAddress(from));
 try
  {
   InternetAddress[] address = {new InternetAddress(to)};
 msg.setRecipients(Message.RecipientType.TO, address);
 msg.setSubject(subject);
 msg.setContent(messageText,"text/plain"); // use setText if you want to send text
 Transport transport = mailSession.getTransport("smtp");
 transport.connect(host, user, pass);
 transport.sendMessage(msg, msg.getAllRecipients());//WasEmailSent = true; // assume it was sent
 return true; 
      
 }
 catch(Exception err) {
      
 //WasEmailSent = false; // assume it's a fail
 return false; 
 //System.out.println("Error"+err.getMessage());
 }
         //transport.close();

 }
}














Monday, February 20, 2012

comment_icon 0 Installing the WASCE WTP Server Adapter


The WASCE Web Tools Platform (WTP) server adapter is a tool for deploying and testing Java EE assets to a WebSphere Application Server Community Edition server. Use the Eclipse Update Manger to install the WASCE WTP server adapter from the Eclipse Update Site for IBM WebSphere Application Server Community Edition.

NOTE: same process is followed for WASCE 3.0 JUST DOWNLOAD 3.0 adapter Click to Download Adapter
Information about this tool can be obtained from the Geronimo development tools site and from the tool's on-line help. The following tips supplement that information.
See Developing portable Java EE assets using Eclipse for information about the JEE Profiling feature.
See Using a server in Eclipse and Deploying in Eclipse for instructions on using the WTP Server Adapter after installing it.

About the WASCE WTP Server Adapters

WebSphere Application Server Community Edition Version 2 provides a new WASCE WTP server adapter which supports Version 1.1.0.x and Version 2.0.0.0 WebSphere Application Server Community Edition servers. These server runtimes can be downloaded from within eclipse after the appropriate WTP server adapter is installed. The Version 2 WASCE WTP server adapter may also be used to run Apache Geronimo Version 1.1.x and Version 2.0 servers, although this is not supported.

Compatible platforms

IBM has tested the WASCE WTP server adapter on Windows and Linux development environments supported by the Server runtime, running on Intel and AMD platforms with the provided IBM 32-bit Java software development kits (SDKs). The Eclipse IDE does support other platforms, which were not tested and therefore, cannot be recommended.
The tool may be compatible with other system platforms and operating system levels, but to obtain support for a suspected defect, you must demonstrate the defect on one of the recommended development platforms.

Installing the WASCE WTP Server Adapter

There are four options for installing the WASCE WTP Server Adapter:
  • the "Download additional server adapters" link
  • the Eclipse Update Manager
  • the updatesite.zip file
  • the deployable.zip file

Installing the WASCE WTP Server Adapter using the "Download additional server adapters" link

  1. In the Servers View panel at the bottom of the screen, right-click, select New and click Server.
    • To show the Servers View panel:
      1. On the Eclipse menu bar, click on Window, select Show View, and click Other....
      2. In the Show View panel, expand Server, select Servers and click OK.
  2. In the New Server panel, click the "Download additional server adapters" link.
  3. In the Install New Server Adapter panel, select "WASCE v2.0 Server Adapter", and click "Next>".
  4. Accept the license agreement, and click Finish.
  5. Click OK to install the server adapter, and restart eclipse for the changes to take effect.

Installing the WASCE WTP Server Adapter using the Eclipse Update Manager


Note: Be sure to install the Prerequisite Software before you attempt to install the WASCE WTP server adapter.
Instructions for users familiar with using the Eclipse Update Manager
  • Add the URL of the WASCE Eclipse Update site (http://download.boulder.ibm.com/ibmdl/pub/software/websphere/wasce/updates/) as a remote site in your Eclipse update manager, and search for features to install from it.
  • To install the Eclipse WTP server adapter for version 2.0 of the WebSphere Application Server Community Edition server, select this WTP Server Adapter:
    • WASCE v2.0 Server Adapter 2.0.0
  • To additionally install the Eclipse WTP server adapter for version 1.1.0.x of the WebSphere Application Server Community Edition server, also select:
    • WASCE v1.1.x Server Adapter 2.0.0
  • It is not necessary or recommended to install a server for development and test from the IBM WASCE Runtimes in the update manager list at this time. The appropriate server will be downloaded the first time you click the Download and install button when you define a new server.
Detailed Instructions
  1. Open the Eclipse Update Manager as follows:
    1. Help, Software Updates, Find and Install....
    2. Select Search for new features to install and click Next.
  2. Create a WASCE Eclipse Update Site as follows:
    1. Click the New Remote Site... button in the upper right corner.
    2. Type WASCE Eclipse Update Site (or other suitable unique name) in the Name: field.
    3. Put the URL of the WASCE Eclipse Update site (http://download.boulder.ibm.com/ibmdl/pub/software/websphere/wasce/updates/) in the URL: field.
    4. Click OK.
  3. Select only the WASCE Eclipse Update Site in the Sites to include in search selection box and click Finish.
  4. Select a mirror and click OK if prompted to do so.
  5. Expand WASCE Eclipse Update Site, and WTP Server Adapters.
  6. Install the desired WTP server adapters
  • To install the Eclipse WTP server adapter for version 2.0 of the WebSphere Application Server Community Edition server, select this WTP Server Adapter:
    • WASCE v2.0 Server Adapter 2.0.0
  • To additionally install the Eclipse WTP server adapter for version 1.1.0.x of the WebSphere Application Server Community Edition server, also select:
    • WASCE v1.1.x Server Adapter 2.0.0
  • It is not necessary or recommended to install a server for development and test from the IBM WASCE Runtimes in the update manager list at this time. The appropriate server will be downloaded the first time you click the Download and install button when you define a new server.
  1. Click Next.
  2. Accept the license agreement and click Next.
  3. Click Finish.
  4. Click Yes to restart eclipse for the changes to take effect.

Installing the WASCE WTP Server Adapter using the updatesite.zip file

Note: This installation option is only recommended if you can not use the Eclipse Update Manager to install code from the Internet due to firewall or proxy restrictions.
  1. Visit the welcome page from the Eclipse Update Site for IBM WebSphere Application Server Community Edition.
  2. Click the link at the bottom of the page to download the updatesite.zip package.
  3. Extract this package to a directory on your machine, and follow the instructions in Installing the WASCE WTP Server Adapter using the Eclipse Update Manager.
    • Instead of using a remote update site, create a local update site from the directory to which you extracted the updatesite.zip package.
    • Detailed Instructions
      1. Open the Eclipse Update Manager as follows:
        1. Help, Software Updates, Available Software
        2. Add Site
      2. Create a WASCE Eclipse Update Site as follows:
        1. Click the  Local Site... button in the upper right corner.
        2. Browse the Local site(extracted folder)
        3. Click OK
      3. Expand WASCE Eclipse Update Site, and WTP Server Adapters.
      4. Install the desired WTP server adapters
      • To install the Eclipse WTP server adapter for version 2.0 of the WebSphere Application Server Community Edition server, select this WTP Server Adapter:
        • WASCE v2.0 Server Adapter 2.0.0 
      • To additionally install the Eclipse WTP server adapter for version 1.1.0.x of the WebSphere Application Server Community Edition server, also select:
        • WASCE v1.1.x Server Adapter 2.0.0
      • It is not necessary or recommended to install a server for development and test from the IBM WASCE Runtimes in the update manager list at this time. The appropriate server will be downloaded the first time you click the Download and install button when you define a new server.
      1. Click Next.
      2. Accept the license agreement and click Next.
      3. Click Finish.
      4. Click Yes to restart eclipse for the changes to take effect.

Installing the WASCE WTP Server Adapter using the deployable.zip file

Note: Use this installation option only if all other options fail.
  1. Visit the welcome page from the Eclipse Update Site for IBM WebSphere Application Server Community Edition.
  2. Click the link at the bottom of the page to download the deployable.zip package.
  3. Stop Eclipse.
  4. Extract this package to your Eclipse directory.
  5. Use the eclipse -clean option after installing the WTP server adapter.

Troubleshooting the WASCE WTP Server Adapter

Use the eclipse -clean option after installing the WTP server adapter

After installing the WTP server adapter, whether it is the first installation or a subsequent installation of a newer version, start Eclipse with the -clean option. This allows Eclipse to recognize and use the newest version of the WTP server adapter.

Views synchronize when saved

While using the WTP server adapter to customize deployment plans, you may want to use both the form view and the source view. When you are using both views, remember that changes made in one view will not be reflected in the other view until the changes are saved. Be sure to save your changes before switching to a different view.

An IP address change can orphan the server

If the server is running on a host where the IP address has been assigned using DHCP, be sure to stop the server before the IP address changes. For example, you are using a laptop with an Ethernet connection, stop the server before you disconnect and switch to a wireless connection. If you don't, Eclipse will not be able to send a shutdown request to the hidden process where the server is running and if the server is not stopped gracefully, some of the server's configuration changes may be lost.
If the IP address changes while the server is running, you will need to stop the javaw process that contains the server or restart the host. In either case, you will have to repeat any configuration changes that were not saved correctly.

Unable to open Deployment plan editor in Eclipse

This error can occur when opening a WASCE- or geronimo-specific deployment plan without having a WASCE server specified as a "Targeted Runtime". An "IllegalArgumentException" may be thrown. To fix the problem, specify a WASCE runtime as the "Targeted Runtime" for the asset as described in Deploying in Eclipse.


Thursday, November 24, 2011

comment_icon 40 Creating A simple DB2 Database Application with jsp


in this session we are going to see that How to Create A simple DB2 Database Application with JSP (java server pages) . Application which we are going to build is login form
Topics Covered :
1. creating database for an application

2.Creating A form and sending data to server

3. connection to database with jsp

Steps to Follow
1.    Create database"VOTERS"

Tuesday, November 22, 2011

comment_icon 5 Installing and Integration DB2 ,Web-Shpere With Eclipse

This Presentation shows that
1.How to install websphere and then How to Integrate that
   with Eclipse (Same steps are required for RAD).
2.How To Install DB2
3. Everything is shown step by step