• Entries (RSS)
  • Comments (RSS)

Keep the generated JSP Source file in WebSphere Application Server

Posted by | Posted in WebSphere | Posted on 30-05-2011

Tagged Under : ,

Keep the generated JSP Source file in WebSphere Application Server

We all know the location of generated Java source file from JSP in WebSphere Commerce. Suppose you are working in an WebSphere Application Server environment, not in WebSphere Commerce and you want to see the JSP source files generated by WAS. If you look in the temp directory of WebSphere, we can see only the .class files. Not the source file. WebSphere Application Server by default does not keep the generated Java source file. However we can instruct WebSphere to keep the generated Java source file in the temp directory. The location where WebSphere keeps the generated Java source file remains same. Of course you can change it, if you want to, by specifying some other configuration parameters.
Read the rest of this entry »

Share

Creating a Hello World RESTful web service with RAD and WebSphere Application Server using IBM JAX-RS

Posted by | Posted in WebSphere | Posted on 22-05-2011

Tagged Under : , , ,

Creating a Hello World RESTful web service with RAD and WebSphere Application Server using IBM JAX-RS

REST is the buzzword now. So its time to learn how to create a RESTful web service now. Here is my simple hello world tutorial on creating a RESTful web service using Rapid Application Developer and IBM JAX-RS. JAX-RS is a Java API for developing REST applications. JAX-RS 1.0 defines a server-side component API to build REST applications. This ia an implementation of the JAX-RS (JSR 311) specification.

All the REST implementations I have seen need a minimum Java 1.5 to run. All these implementations use annotations. So my code will not work on WebSphere Application Server 6 and below versions. The minimum required version is WebSphere Application Server 6.1. I have tested these examples only in WAS 7. You need to have Feature pack for Web 2.0 for WebSphere installed on your application server. So once you have your app server ready with Web 2.0 feature pack installed then you have pretty much everything to get started. Follow the below steps to create your first hello world RESTful web service with RAD and WAS 7. For my development purposes I was using RAD 7.5. But I am sure that the following steps will work even for other RAD version too.
Read the rest of this entry »

Share

Sending an e-mail using WebSphere Mail session settings.

Posted by | Posted in WebSphere | Posted on 27-10-2008

Tagged Under : , , , ,

Sending an e-mail using WebSphere Mail session settings.

Yesterday I had posted about configuring a Mail Session in WebSphere Application Server admin console. Today I will be talking about sending an email from your JSP using the configured mail session.

To access the Mail session for sending your email you need to do a JNDI lookup from your JSP file. The complete code for sending email using the Mail Session settings is given below.

	// Look up mail session
	javax.naming.Context context = new javax.naming.InitialContext();
	javax.mail.Session mailSession = (javax.mail.Session) context.lookup("mail/localmail");
	javax.mail.Message msg = new javax.mail.internet.MimeMessage(mailSession);
	msg.setFrom(new javax.mail.internet.InternetAddress(fromEmail));
	msg.setRecipients(javax.mail.Message.RecipientType.TO, javax.mail.internet.InternetAddress.parse(toEmail));
	msg.setSubject(mailSubject);
	msg.setText(mailBody);
 
	javax.mail.Transport.send(msg);
	System.out.println("Message Sent");

I have used the JNDI name directly for accessing the mail session settings. A better alternative is to use the resource reference in your JSP/Servlet code. The advantage of this approach is that we don’t need to alter the code even if our configuration name changes.

To add a resource reference opens your web.xml. Go to References Tab. Click on Add and select Resource Reference as the reference type and enter the details. For type select javax.mail.Session from the drop down box. If you are using resource reference, your lookup code will change to

	javax.mail.Session mailSession = (javax.mail.Session) context.lookup("java:comp/mail/localmail");
Share

Configuring a Mail Session in WebSphere Application Server

Posted by | Posted in WebSphere | Posted on 25-10-2008

Tagged Under : , , ,

Sending emails is necessary in almost every web application. If your Web application is hosted in WebSphere Application Server you can lookup a Mail session from your servlet or JSP using JNDI. Today I will be explaining how to configure Mail Sessions in WebSphere Application Server? To configure your mail session settings follow the steps.

1. Login to admin console. The admin console url will be http://localhost:9060/admin if you are using the default port and your server is localhost. Else change the port and server name.

2. Click on Resources -> Mail providers.

3. From the page opened click on Built-in Mail Provider.

4. From Built-in Mail Provider page click on ‘Mail Sessions’ link.

5. The Mail Sessions page will be opened. Now click on New.

6. Mail session configuration page appears. Enter the details. Here Name is the administrative name of the JavaMail session object, JNDI name is the name of the resource. If your mail server needs a username and password for sending emails, enter Mail transport user ID and Mail transport password too.

7. Apply and Save the changes to master configuration.

You are done with the configuring your mail session settings. Now you can use the configured the mail session for sending mail from your web application using a JNDI lookup.

Share

Changing the default port in WebSphere Application Server

Posted by | Posted in WebSphere | Posted on 27-08-2008

Tagged Under : , ,

Changing the default port in WebSphere Application Server

Sometimes we may need to change the default port of a WebSphere Application Server installation as a security precaution or for some other reasons like for coexisting with another WAS installation on the same machine. Moreover it’s always better to change the default ports in production environments. You can follow the below steps to change the default http port.

1. Logon to your admin console :-) (Obviously this is the first step. When we have such a nice interface available why we need to think some other options?).

2. Click on Servers -> Application servers -> .

3. Click on Ports link under communications, under the Configuration tab. (If you expand the Ports section click on details).

4. Click on the port name you want to change. Here I am changing the default http transport port. So I clicked on WC_defaulthost port.

5. Enter the port number you want to use in port text box. (Please make sure that port is not already used by some one else). Apply and save the changes. After entering the new port the WC_defaulthost will look like the one in the below image.

6. Now click on Environment -> Virtual Hosts. This page would display all the virtual hosts present in the system.

7. Click on default_host.

8. Click on Host Aliases.

9. Click on the port you want to change.

10. Enter the new port number.

Apply and Save the changes to Master Repository. You are done. Restart the server and now the server will start binding to the new port.

Share