Segunda-feira Out 27, 2008

AJAX and NetBeans - jMaki and ZK

Hi everybody,

Last Thursday I did a Tech Demo about developing AJAX web apps using the powerful NetBeans 6.1 at Federal University of Rio de Janeiro.

I started talking about AJAX and how it improves usability and creates user friendly interfaces for the Web. Many people thinks that having ajax apps will overload the server and network just because you have a prettier interface. People have the idea that how more sophisticated is the app, heavier it will be. AJAX shows that it's not true.

The division of concepts let the server deal only with the data requested from Javascripts at client side. The interface refreshing is done all by the browser. So, instead of sending full and big HTML blocks to the client each time he refresh or navigate to a different page, the server just send the information requested and the browser deal with page drawing dynamically.

A great doubt about developing an AJAX app is to choose a framework. I suggested 2!

First I talked about jMaki. (http://jmaki.com/)

I did a demo showing the features of jMaki framework and its cool plugin for NetBeans.

jMaki is a client-server framework that encapsulates many AJAX components from other frameworks in the form of a Widget. With the NetBeans plugin, it let you create your pages dragging and dropping widgets to your JSP. You only need to customize your page changing the CSS file as you like and choosing the best widgets to compose your web page.

To start learning about jMaki, I suggest these links:
NetBeans jMaki Introduction Tutorial
jMaki Screencast
To get a little more advanced learning, try this Another jMaki NetBeas tutorial with RESTful WS

Later I started talking about ZK framework to build AJAX RIA using NetBeans.
When a friend showed me ZK, I got really impressed. It's a complete framework and it let you develop your app programming only in Java.

Yes! All the server side AND the client side scripts can be written in pure Java language (sweet Java)! Check some videos and examples at ZK Home Page

I did a simple demo using ZK to build a Web Telephone List.

WARNING: I don't use a database on this demo, but it's just to leave things faster. On a real world implementation , you should really consider that, specially because ZK has great tools to deal with Database and Persistence. If you understand Brazilian Protugese, check this blog post.

Now let's start our demo.

First, install NetBeans ZK plugin:
There are 2 plugin options:
1. ZK Designer plugins for netbeans 6.1
2. REM for NetBeans 6.0

The first let you develop your ZUL web pages dragging and dropping the components into your xml, but the second one is the one with code completion and highlighting.

Actually, in a very near future they will became only one plugin. Stay tuned for next release of REM plugin because it will came with the visual ZK designer bundled too!

Download the plugin and install it on NetBeans through the Tools->Plugins window.

For my Demo, I chose the first plugin that let me create my pages faster using drag n drop.

So now, let's create a New Project.

1. Go to File -> New Project
2. Choose a new Web / Web Application
3. Choose a name for your project (like ZKDemo)
4. Choose your server (GlassFish)
5. Choose the framework you would like to use. Here you must choose ZK!

The project opens with two index files: the index.jsp and index.zul. Delete the JSP and keep the ZUL. ZK support JSP includes, but its main ajax components are arranged to compose your web page on a XML file called ZUL file.

The index.zul file comes with a simple window page like this:

Try some drag and drop with the ZK components of the palette and then Run you project to check some ZK features!! Not all the ZK components are already on the palette! To see a full list of ZK Components, check: ZK Explorer!

For our Telephone List project you will need this index.zul file.
Copy it's content on your index.zul.
You will also need the catalog.zul file that is included on our index.zul and the catalog.zs file that is used by the ZSCRIPT tag on the begining of the index.zul file.

Just save catalog.zul and catalog.zs on your project page at your NetBeansProjects/YourProjectName/Web folder!.

Then go to NetBeans and open the ZS file. Look! It's Java code! No Javascript in here :D! See that it does 2 imports:

import ufrj.zkdemo.Catalog;
import ufrj.zkdemo.Contact;

This classes need to be created! But it's quite simple! Remember that if you create your classes on a diferent package, you will need to update the ZS file with yourpackage.Catalog and yourpackage.Contact imports!

Download Catalog.java class.
Download Contact.java class.

And put them on your project's source code packages!

Now Run your application and enjoy your veeeery simple telephone ajax catalog! See that, since we are using Lists and a Map to store the data, every time you Refresh your Web Page, you will have your telephone data ERASED!! Yes, this is not a very useful Tel catalog, but I encourage you to improve this project using a Database! ;)

Cheers,
Jonas

Quinta-feira Out 02, 2008

Software Freedom Day Report!

Hi everybody,

I know I'm late. I should have written this post last week, but I was quite occupied and forgot about sitting and writing the blog post.

The SFD event on Rio de Janeiro was fine! We had an attendance of 36 people and many of them were excited about what the OpenSource could give them.

About 10 o'clock of the morning we started the event speaking about the Software Freedom Day, Open Source and Sun intentions on this world! Next, we had a really great talk given by Magno Cavalcante, RioJUG's Leader and Sun Java Champion, about the Web 2.0 and people's value, including a lot of important concepts about software freedom, market and development.

After the lunch, we've kept talking about open source, showing great features of OpenSolaris 2008.05, VirtualBox and NetBeans. We explained the Sun Open Source University Meetup initiative to the students and invited them to join it! In the end, we had an OpenSolaris installation inside VirtualBox and we raffled give-aways!

Lots were said about the importance of software freedom! And how much the great companies support it, specially Sun!

That's it!
I will be probably posting something more technical here, like the SFD demo about NetBeans+AJAX that I have done.

Cheers!
Jonas

Segunda-feira Set 15, 2008

Software Freedom Day

Hey all,

Next Saturday we will have a great event to attend: The Software Freedom Day!

It will take place here at Rio de Janeiro on the Nova América Shopping Center at Estácio de Sá University Campus. We plan to have a lot of fun talking about FOSS and its importance to industry and society! We will have demonstrations, cool talks and install fest, showing great work done by the community!

Sun support FOSS and SFD! So, I will be there with Pedro Reis, another CA from Rio, shaking things at our event!

Go there to get some cool ideas(and gifts!)

;)



Segunda-feira Ago 18, 2008

Developer Web Days 2008

Hi everybody,

This Friday I will give a Tech Talk at Developer Web Days 2008 meeting, here on Brazil.

At 9:00 o'clock, I will be in Room A, talking about Web Development using AJAX and NetBeans:
I will give a little overview about AJAX and show how to easily construct and deploy AJAX content on your projects without Javascript, using the outstanding jMaki framework and the amazing ZK framework. I will possibly show the Dynamic Faces project with AJAX too.

at 18:30 o'clock, I will be attending Room D, talking about Service Oriented Architecture (SOA), Web Services and EJB. On this presentation, I will talk about how to support SOA with EJB, using them as web services and orchestrating them with BPEL, constructing your own composite application. Using the Open ESB SOA plugin for Netbeans, I will make almost everything visually, what makes it easy to understand and use later.

You can find more Information about the event at http://www.devmedia.com.br/webdays2008/index.html

After the presentations I will post the demos' Tutorials right here on this blog!! Stay tuned.

Cheers
Jonas

Quinta-feira Ago 07, 2008

Deploying Web Services on other Servers using NetBeans

Hey everybody!

A friend made a question on the WebServices and JSP on NetBeans 6.1 post about deploying Web Services on other servers, like Tomcat. It could be, actually, a problem, because many will say that you won't be able to deploy WS on Tomcat. That is not true. If you are using a version of JDK greater than 1.6.0_04, nothing needs to be done, you will just have to use TomCat on your project. If you are using older versions, you may check this link http://wiki.netbeans.org/FaqEndorsedDirTomcat.

I will do some demonstration here using Tomcat 6.0.16 that cames bundled with NetBeans 6.1 using JDK version 1.6.0_07 and JBOSS version 4.2.2 that I downloaded some time ago from www.jboss.org.

First, let's do our simple WS - that will receive a name as a parameter and return Hello name. Quite simple ;)
I will not get into details here because the other post has already covered the Web Service easy creation on NetBeans.
Just ask for a New Project on NetBeans (File->New Project or Ctrl+Shift+N). Select a Web Application, using the Web Category and press Next. Choose a name for your application (for example: HelloTom) and press Next again.
On this screen, you choose the server you will use for the project, select Tomcat.

Press Finish.
After project creation, right click the project name (HelloTom) and select "New->Web Service" from the drop down menu. On the wizard screen, define the Class and package name for your WS (like Hello and hello.ws). NetBeans will open your WebService for visual development.

Click on the "Add Operation..." Button. On the wizard screen, select the name of the operation (i.e. helloOperation). Do not use just 'Hello' as the name of the operation because it will be interpreted as the WS class constructor and you may get confused. Leave the Return Type as String but add a String parameter called "name". Click OK and see that the visual designer added your operation to the WS Operations list on the screen. Right Click the helloOperation and select "Go To Source".

On the Source edit the Operation code like this:

@WebMethod(operationName = "helloOperation")
public String helloOperation(@WebParam(name = "name")
String name) {
       return "Hello "+name;
}

Done. Now, right click your project name (HelloTom) and choose Run. If Tomcat is up and running, it will show the Hello World! message for you that is on its default JSP page.
The "Test Web Service" functionality we have used on the other post will not be avaiable on Tomcat like on Glassfish, but you can easily try your WS creating another project that access the Web Service on the server. If you have problems creating a project to access the WS, check the WebServices and JSP on NetBeans 6.1 post.

Now let's add another server to NetBeans and make use of it.

Click on the Services tab, on the left side of IDE. Righ Click the Server node and click on "Add Server..." just like the next picture:

The Wizard starts and you need to choose the Server type. Here, on my example, I chose JBoss Application Server (but there are many others):

Press Next. On the next screen, select the server location (ie, where is it installed) and press Next again.
On this screen, you will need to select a server configuration, I've just left the default:

Press Finish. The Server will be added to your Server list on the IDE. You may right click on its icon and Start the server just like this (Iniciar=Start, in Portuguese):

Wait until JBOSS starts and let's test it.

Go Back to your projects clicking on the Projects Tab. Right Click the Hello Project and select Properties from the drop down menu. On the Properties screen, select the Run category (that may be the last one) on the left panel just like the next picture (the picture has somethings in Portuguese where Run=Executar). After selecting the Run category, you will see (on the right side) the option to select the server where you want to deploy your project, we will have Tomcat selected, change it to JBoss Application Server.

Press OK and wait while NetBeans save your project's Settings. Now your can Run the Hello project again and it will be deployed directly on JBoss. The "Test Web Service" functionality is not avaiable on JBoss too, you need to create another simple project that access the Service on the server. It'easy and described on the WebServices and JSP on NetBeans 6.1 post.

That's it! There is no limit!
Cheers!

Terça-feira Ago 05, 2008

InfoWorld's 2008 BOSSIE Award

Hi everybody,

On this annual Best of Open Source Software (BOSSIE) Info World Award, MySQL got the prize for best Open Source Database!
Check it here: Database

MySQL is just amazing!

VirtualBox 1.5 got the best Open Source Desktop Virtualization Tool! See the link: Desktop Virtualization

A good thing to say is that VirtualBox has became Sun xVM VirtualBox and the 1.6.2 version had many improvements comparing to the 1.5 one! So, VirtualBox today is even nicer than it was some months ago!

OpenOffice got the best Open Source Productivity Suite! Check the link at InfoWorld: Productivity Suite

OpenOffice is very cool and "just what you need" from an Office Suite. No exaggerated fancy graphics, no problematic extensions and compatibility issues, no price ;) . Just easy-of-use and the necessary things to make your work!

Make your life easier!
Cheers,
Jonas

Quarta-feira Jun 18, 2008

Firefox 3 Record

Over 8,000,000 downloads in 24 hours!

Amazing number!

Congratulations Firefox!

Firefox 3

Terça-feira Jun 17, 2008

Firefox 3 Download Day

Hi Everybody!

There is still time!

Let´s download it!

Firefox 3 Rocks!


Download Day 2008

Cheers

Sexta-feira Jun 06, 2008

Self-Healing SAMP with OpenSolaris 2008.05 and it's SMF

Hi Everybody!

     Today I'm doing a review about the new OpenSolaris 2008.05, the one released from project Indiana on 05/05/2008.
     OpenSolaris 2008.05 has all the benefits of Solaris' Kernel and uses ZFS (the greatest file system of the planet) as its native file system. The first impression I had when I installed was its fastness. It's certainly much faster than Ubuntu 8.04, Fedora 9 and, of course, Windows. I'm using it now to do all my work and I'm really satisfied. See my desktop screen:

     OpenSolaris cames with Java installed, Firefox and ThunderBird, Pidgin, GIMP, eVince and many others Gnu Tools.The Flash plug-in is very easy to install, Firefox is prepared to do everything for you... so, no need to download it apart and then configure Firefox yourself to make it work. It just install and work for you.

     One of the greatest features of Solaris, for me, is it's Service Management Facility, aka SMF, that gives Solaris the Self Healing ability. Different from Linux, the services are not started and managed through the RC scripts manually, they are controlled by SMF, that manages dependencies, status, errors and organizes everything. If something goes wrong, SMF takes an attitude to repair the situation automatically. If it has no autonomy to full repair a problem, it gives great feedback, instructions about possibilities to fix the problem and very useful logs. OpenSolaris is smart!

     To challenge the OpenSolaris way of use, I decided to put a full SAMP platform to work on it, integrating that with Solaris SMF Self Healing System.

And the steps I followed to do it will fit on a single blog Post! ;)

     For those that are not familiar with some terminologies, SAMP means: Solaris+Apache+MySql+PHP ... a fast and furious development platform.

     The First Step was to install Apache, MySql and PHP. OpenSolaris cames with a Package Manager that downloads, configures and installs the packages for us, with no troubles and headaches about dependencies. Next is a screen shot:

     First, I searched for apache and asked the Package Manager to Install Apache 2.2 (SUNWapch22), FastCGI plugin (SUNWapch22m-fcgid), and PHP5 module for Apache (SUNWapch22m-php5). Second, I searched for mysql and asked the manager to install MySql 5 (SUNWmysql5), PHP5 Extension module(Core) to connect to MySQL database (SUNWphp524-mysql) and SUNWmysql-base. The last step was the search for php. I asked Package manager to install PHP Server 5.2.4 (SUNWphp524), Core components of PHP server (SUNWphp524core) and SUNWphp524usr.
     All the Packages are available on opensolaris.org repository.

     No headache to install SAMP. The three applications were installed on my system on /usr , /etc and /var directories separating (not that exactly, but...) executables/libs, configuration files and functional data, respectively.

     Then, I stepped to the interesting part: to configure Apache, MySQL and PHP to work together and to be part of SMF! I've started with MySQL.

     Created a my.cnf file at /usr/mysql/5.0 copying the my-small.cnf from /usr/mysql/5.0/share/mysql and renaming it:

# cd /usr/mysql/5.0
#cp ./share/mysql/my-small.cnf .
#mv my-small.cnf my.cnf

     Then, I've run mysql_install_db, running the script inside /usr/mysql/5.0/bin:

#cd /usr/mysql/5.0/bin
#./mysql_install_db

After that, just put mysql user as owner of /var/mysql folders:

#cd /var
#chown -R mysql:mysql ./mysql

     So, it was already possible to start MySQL through '/usr/mysql/5.0/bin/mysql_safe &' command. To stop MySQL, we may use 'pkill mysql'. I did it to test if everything was going OK. Then I configured Apache to work with PHP.

     First, I've edited the httpd.conf file on /etc/apache2/2.2 . I've searched on httpd.conf file for ServerName and ServerAdmin variables. I've left the ServerName variable set to 127.0.0.1, but it can be changed to an specific server name. Then I changed the ServerAdmin value to a valid e-mail.

     Next, I searched for <IfModule mime_module> tag on httpd.conf. And, Near the following lines:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

I've added a third line with: AddType application/x-httpd-php .php

It stayed like that:

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php

     That's all for httpd.conf. Now, there is only php.ini left. I've just copied /etc/php5/5.2.4/php.ini file to /etc/apache2/2.2/:

#cd /etc/apache2/2.2
#cp /etc/php5/5.2.4/php.ini .

And then opened it to edit. I've only needed to find the block:
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

And add the following line after the comments:
extension=mysql.so

     So far so good. Everything is configured and working. You can try starting apache through '/usr/apache2/2.2/bin/apacheclt start' and use a little PHP script to test (Start MySQL too). Create a file with these lines:

<?php
     echo "Hello World!
";
     $conexao = mysql_connect('localhost', 'root', '');
     echo $conexao;
?>

and save it inside /var/apache2/2.2/htdocs with a name like myTest.php . Then, open your browser and type "http://localhost/myTest.php" . Apache and MySQL should be running (you may check it using the 'ps' command)! The Browser should display a message like:

     You may see I haven't configured a password for MySQL root user! That's really bad for a real system! You may change root's password on MySQL and create other users to use the databases as you need. But my intention here is just testing.

Now Let's put Apache and MySQL inside SMF!

     To set up a service inside SMF you need a script that knows how to start and stop your service (like the old rc scripts of linux) and a XML manifest file that gives more information about the service to SMF like dependencies and other characteristics. There is not so much headache to create these files. The Method script, as I mentioned, is not very different from an RC script, and for the XML manifest, that could sounds more complicated, there is a tool on opensolaris.org that helps you to generate your manifest file automatically, have a look at EASY SMF - http://es.opensolaris.org/easySMF/.

     Anyway, Apache and MySQL are famous services and, because I was in a hurry, I've just searched the Internet to see if there was something already done. And there it was. I've edited the scripts and manifests files from these links to put my services under SMF management.

http://systemsadmin.info/solaris/articles/setting-up-smf-for-apache-and-zope-on-solaris-10
http://www.sun.com/bigadmin/content/submitted/mysql_smf_tip.html

Thanks to Chris Miles and William Pool for the files!

     I've had to edit the original method scripts and manifest files because many installation details were different from what I found on the originals, like the paths to many important files. So I've adapted them to work directly for OpenSolaris Package Manager Installations.

     So, you can have the method scripts here. Just copy them into /lib/svc/method :

Apache Method: apache2
MySQL Method: svc-mysql

>> After saving them on method directory, chmod them into 555 permission (read and execute) (( '# chmod 555 apache2 svc-mysql' ))

     And here are the Manifest Files. They will be copied into different directories:

Apache2 Manifest: apache2.xml

>> Save it inside '/var/svc/manifest/site' directory and chmod it to 444 permission (read only) (( '# cdmod 444 apache2.xml' ))

MySQL Manifest: mysql.xml

>> Save it inside '/var/svc/manifest/network' directory and chmod it to 444 permission (read only) (( '# cdmod 444 apache2.xml' ))

Good. Now the last step. Import them into SMF through the commands:

# svccfg -v import /var/svc/manifest/site/apache2.xml
# svccfg -v import /var/svc/manifest/network/mysql.xml

If you have Apache2 and MySQL running on the system, turn them off (you may use 'pkill mysql' and 'apacheclt stop'). To start your services, now you may use:


# svcadm -v enable apache2
and
# svcadm -v enable mysql

and

# svcadm -v disable apache2
and
# svcadm -v disable mysql

To turn them off.

     It's possible to see their status through the command:

# svcs -a | grep apache2
# svcs -a | grep mysql

(svcs command list the enabled services; -a option show all the services, enabled and disabled ones)
You may see if there is any problem with your services running the following command:

# svcs -x

If something weird makes your Apache or MySQL go down killing their processes (try it yourself), SMF will take care of it and put the services up and running again!

Nice, isn't it?? And quite easy too!
That's it. Through few steps, now I have my SAMP platform configured and under OpenSolaris Self-Healing system.

Cheers!
Jonas

Quarta-feira Jun 04, 2008

WebServices and JSP on NetBeans 6.1

Turn The Very Easy mode On and Play

Hi Everybody! Today I'm writing a little review (that may sounds like a tutorial) about the easiest way to write a simple Web Service and use it on your projects. See, you don't need to be an expert on Web Services nor JSP nor Web Technologies, because we are using NetBeans 6.1, the only IDE you need to learn something big on the very easy way.

From 6.0 to 6.1, NetBeans has grown faster, more stable and more practical. I haven't found anything specific about the development of WS using the New NetBeans, only using the 5.5 version. That's why I decided to write it here.

I've downloaded the Web & JavaEE Pack of Netbeans 6.1 on NetBeans Download Center. It comes with TomCat and Glassfish bundled, but we can use others Containers too, like JBOSS, for example. On the Services tab, on the left side of IDE, you can find the servers that NetBeans is using.

You may click on 'Servers' and choose 'Add Server...', A list of 'Connectible' servers appears. You will be able to connect Servers like JBOSS, WebSphere, BEA WebLogic, Sailfin, and, of course, TomCat, Sun Application Server and Glassfish, all out-of-the-box. (They just need to be installed, TomCat and Glassfish can be installed during NetBeans Setup).

Now Let's Start our Web Service. We just need to go to File -> New Project (Ctrl+Shift+N), choose Web on Categories and Web Application on Projects. Then Press Next. Choose the name and folders of your application and press Next again, then choose the server where your Web Application will be deployed. You will see the screens below (but they will be shown separated, through the next steps, not layered). On the End, just press Finish. (If you press Next, you will be able to choose a framework like JSF or Struts)

Now we have our Web Project. A Default index.jsp is there waiting - delete it - we are doing WebServices for now. Select the Project, click on the Project name with your right mouse button, choose New -> Web Service... on the list. NetBeans will then open a tab on the development area showing it's graphical interface to create Web Services, just like that:

A Web Service is quite like a java class (it's a .java file), in which the methods are called Operations. A Web Service may have many Operations. So, let's create our Operations clicking at the 'Add Operation...' Button. A window will pop up, asking the details of your operation, just like this:

I created two operations, one to add a user (the addUser Operation show above) and one to check if the user has been added to the list, like a login check (the checkUser Operation). NetBeans shows me the details graphically:

(If the image is too little, click with your right mouse button and choose View Image, The blog may be resizing the pictures, making them unreadable)

Now we go to the Source Code (Clicking on the Source button on the development area, just below the file tab)! You can click with the right button on the Operation and choose 'Go to Source' option on the Menu.
At The Source you see all the Structure of your code. Out of the methods scope, create a List of Users like:
>> List users; . There is no User Class defined in the package, so click on the light bulb near the code and ask NetBeans to create User Class in the package for you:

Go to User Class source code and add two parameters to the class: String username; and String password;
Then we ask NetBeans to create the getter and setter methods, and to override equals and hash code methods. How?? Easy! Just click with the right button and select Insert Code: A little menu will appear:

and we may choose to generate many kinds of methods. For example, if we choose to generate equals and hash code, another windows will pop up asking about which parameters of the class do you want to use, just like this:

Any doubts about the User Class, see it's source here.

Back to the Web Service source code, now we have to implement the addUser and checkUser Operations. They are both easy, see the idea of the code below:
To add a user:
   User user = new User();
   user.setLogin(login);
   user.setPassword(password);
   if(!users.contains(user)) { //if the user is not already on the list
     users.add(user); // add the user and return true to say everything has gone OK
     return true;
   } else { // user is already on the list.
     return false; // Return false to say no one has been added to the list
   }

To check the User:
   User user = new User();
   user.setLogin(login);
   user.setPassword(password);
   if(users.contains(user)) { //if the user is on the list
     return true; // let it login, return OK
   } else { // user isn't on the list
     return false; // return 'there is a problem here'
   }

The Full Web Service Code can be viewed (and copied ;) ) here.

Now, we may just Run our Web Service, and see that it's Running on the Service tab under your container's Web Applications.

But, let's Test it to see if it's really working!
Expand the Web Service Folder of Your Project and select your Web Service. Click with the right button and select Test Web Service:

Something like that will be opened on your Browser:

Amazing, isn't it?? You may test your Web Service as you want, and get answers like this:

Tip: Add some users using the addUser Operation and see if checkUser works returning True for added Users and False for unknown users.

Now Lets quickly create our JSP! Yes... really fast.

Create a New Project (File -> New Project). Select Web / Web Application Again!
Now we may use the 'index.jsp' file. There is a palette on the right side of the IDE, you may drag and drop HTML Form Items to your code. You need a FORM that collect user's login and password. Something like this:

<form name="loginForm" action="checkLogin.jsp" method="POST">
<input type="text" name="login" value="Your Login" />
<input type="password" name="pwd" value="\*\*\*\*\*\*\*" />
<input type="submit" value="Submit" name="loginSubmit" />
</form>

The Form action is checkLogin.jsp... so Let's create it. Click on your new Web Project name with the right button, go to New -> JSP. Create the JSP named checkLogin.
Now let's add a client to our WebService, the one we created on the other Project.
Click with right button on your New Project Name, go to New -> Web Service Client...
Select the Project where the WebService has been Created, just like this:

There are other ways to get the Web Service (thought WSDL link, for example), you may explore it yourself latter.
Wait while NetBeans process the Web Service into your New Project, you will be able to see it on the project. Like this:

(On the properties of the webservice, you will find the WSDL address of the service, then you can visualize it o the browser, and see it's XSD too.)

Now, go to the JSP code. Below the Hello World default Message, click with the right button and select:
Web Service Client Resources -> Call Web Service Operation
A window will appear asking which operation you want to choose:

Choose checkUser and NetBeans will do all the code for you. Of course, you need to put some by yourself. Our FORM, on index.jsp, send it's data using POST. so let's get these values from POST. Add the fallowing code before the Web Service process, just after the 'try {' put by NetBeans on your JSP:
    String uname = request.getParameter("login");
    String pwd = request.getParameter("pwd");

Then, change the generated code lines to point to your collected data:
    java.lang.String login = uname;
    java.lang.String password = pwd;
    // TODO process result here
    boolean result = port.checkUser(login, password);
    if(result) {
       out.println("User Logged");
    } else {
       out.println("Access Denied");
    }
    } catch (Exception ex) {
       out.println(ex.getMessage());
       out.println("Unable to operate the WebService");
    }

Any doubts, check index.jsp and checkLogin.jsp codes.

Then, ask NetBeans to Run the index.jsp file. The browser will be opened with your JSP page asking a login and password (Just after the Hello World! message). Try the login and password you have added using the Test tool and see if checkLogin grants access to the users or not. Try the users you have added and another ones. If no User is recognized, the data on the Server may has been lost, try adding new login/passwords using the Test Tool or using the addUser Operation, now you know how to do it.

You don't need to use a Web Interface to access your Web Service, you can create a Java Project with a GUI that connects to the server and use the Web Service, or use a Mobile, everything through NetBeans. Just Explore!

Remember!! We are keeping this user information on a List inside the Memory (through the Web Service inside the Server). If you restart the Server or the IDE, all information may be lost. This example is just a simple one, to do a more professional system, you should use a database, this way your data will be kept safe.

Hope you enjoy that! The text is quite big, but it's simple to do that!
Any doubts or tips, just send a comment! ;)

Cheers
Jonas

Sexta-feira Mai 30, 2008

OpenSolaris DAY Statistics

Hi Everybody!

It's a pleasure for all Sun Campus Ambassador Team!
I'm here to announce the OpenSolaris Day Numbers!

3 days of presentations.

24 Universities
31 presentations
1819 people heard about OpenSolaris 2008.05 through our event!
- 1732 Students
- 85 Professors / Researchers

The List of Institutions:
Centro Universitário da FEI
Centro Universitário Estadual da Zona Oeste - UEZO
Centro Universitário Salesiano de São Paulo - UNISAL
Faculdade Anhangüera de Taubaté
FATEC - Cruzeiro
FATEC - Zona Sul
Instituto CPTEC/INPE
Pontifícia Universidade Católica do Rio Grande do Sul – PUC RS
SEBRAE
Universidade Católica de Brasília
Universidade de Santa Cruz do Sul
Universidade de São Paulo - USP
Universidade do Vale do Rio dos Sinos - UNISINOS
Universidade Estácio de Sá - UNESA
Universidade Estadual Paulista - Rio Claro - UNESP
Universidade Estadual Paulista - S. J. Rio Preto - UNESP
Universidade Estadual Paulista – Bauru - UNESP
Universidade Federal da Bahia - UFBA
Universidade Federal de São Carlos - UFSCar
Universidade Federal do Rio de Janeiro - UFRJ
Universidade Federal do Rio Grande do Norte - UFRN
Universidade Federal do Rio Grande do Sul - UFRGS
Universidade Lemos de Castro
Universidade Paulista - UNIP

And cheers for all Brazil's Sun CAs that made that happen!
Alex Rafael Branti, Douglas Ramiro, Fábio Augusto, Gabriela Souza, João Paulo Samara, Jonas Dias, Leonardo Alves, Leví Silva, Luiz Felipe Aquino, Marcelo Arbore, Oscar Tanner, Pedro Reis, Ramon Lopes, Ricardo Severo, Silveira Neto, Stephania Silva, Thiago Gonzaga, Tom Mix Petreca, Vitorio Sassi!

Segunda-feira Mai 05, 2008

The New OpenSolaris Released!

HI ALL!!

A great conquest! A Great OS! The release of the future! ;)

Download it NOW!!
The amazing new OpenSolaris!! At www.opensolaris.COM

GET IT!!

Cheers!

Sexta-feira Mai 02, 2008

opensolaris DAY BRAZIL Invitation

Hi all! Let's make it HUGE! OpenSolaris DAY BRAZIL!






Mascotes
Nos dias 5, 6 e 7 de maio o Brasil vai parar!

Todos aguardando pela mesma coisa...

Outro Jogo de Futebol?

Certamente não.


opensolaris DAY Brasil

 6 de maio na sua Faculdade

Anfiteatro Maria Irene, NCE - CCMN - UFRJ

Às 12hs

"open" popcorn and "free" source - Bring your appetite for future

Terça-feira Abr 29, 2008

TACC Ranger Tour

Hi everybody,

A video tour through Ranger, the second most powerfull super computer of the world.
But more than that, what makes it greater than the 1st position of the rank is that it is also a commercial solution of Sun... if want to buy a supercomputer like Ranger for you or your enterprise, you can do it!

"The Sun Constellation System is the world's first open Petascale computing environment combining ultra-dense high performance computing, networking, storage and software into an integrated system that delivers massive scalability, dramatically reduced complexity and breakthrough economics. The Sun Constellation System brings key innovations to market and is designed for radical simplicity that puts a new level of high-performance computing within reach for customers, whether they are pushing the limits for what is physically possible or if they are hungry for more performance from HPC solutions in production today." - http://www.sun.com/servers/hpc/SunConstellationPreview.jsp

Segunda-feira Abr 28, 2008

JavaME and WebServices Tech Demos

Hi all!

Last week we (me and Luiz Aquino) did great Tech Demos at NCE at UFRJ!
On Thursday, we talked about the Easy JavaME development with NetBeans. Because of the holydays, we had a not very high attendance of 21 interested people, including students and a professor.
On Friday, we talked about the Easy JavaEE WebServices development with Nebeans. We had a greater attendance of 29 interested people. It was nice and most liked the drag and drop style of constructing things on NetBeans.

The Projects of the demos are here:

The main WebService that offers the login, addUser and removeUser Operations:
Download

The GUI clients that offer interfaces to add users and to log in.
Download

And the Mobile Phone Project that offer the mobile interface to log into the server.
Download

One more thing!

NETBEANS 6.1 final release is now avaiable!!


have a look at:
http://download.netbeans.org/netbeans/6.1/final/

Now with Early Access to PHP out of the box too!!
And you may use NetBens only as a C or Ruby or PHP IDE... you don't need to have JavaSE module installed... anyway I strongly recommend using NetBeans for everything, hehehe! ;)

Cheers
Jonas

About

Well... Let's keep this blog updated for now on!!

Search

Categories
Archives
« Abril 2014
SegTerQuaQuiSexSábDom
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today