My blog has moved!

You should be automatically redirected . If not, visit
http://www.atriagrawal.com
and update your bookmarks.

About Me

My photo
I am currently pursuing my Masters at University of Southern California in Computer Science.

Saturday, August 29, 2009

Developing an application Vs successfully running it on LAN

I guarantee you that making a web application may not seem to be a very big deal but trust me deploying it on INTRANET (or internet) and successfully running it with many many simultaneous users is quite a deal !!

I created the quiz engine in around 3 days but to make it successfully run on my college's intranet, I had to modify the main part of my application around 4-5 times. This took me around 5 more days. But this indeed has taught me a lot of things which I would like to share.

First off, always use a standard method of coding. Never go for the so called "jugad" technology. In the end you will have to pay heavily(in terms of your time) for using "jugad" in your code if there has to be any modification at any point of time in your application. Some very important points to be kept in mind are:

* Always use one single connection for connecting to your database for the whole application for every user. Don't open and close connections every time you have to connect to the database.

* Keep your concept of STATIC variable very very clear in your mind. A static variable declared in any bean(java class) will always have the same constant value throughout the application scope for each and every user until and unless changed. Once the value is changed it will remain constant, again, for every user and for the scope of the whole application

* Try using AJAX as it makes the application very light in terms of the request and response from the user to the server and vice-versa.

* Keep a check on the security aspect of your applications (people tend to test your application with every possible way out!). Keep the application tightly constrained.

* Try configuring your server on LINUX only. It helps a lot and of course it is open source. Split your database server and application server so that the load is distributed.

Tuesday, August 25, 2009

splitting the database and the application server

Wanna split the database server and the application server???? Wanna get some more performance with your servers ?? follow these simple steps and feel the difference........

First off never make a server as your windows XP machine if you want to support more than 5 users simultaneously, it will really make a mess of your application. Always use linux(any distro) as your server. I ususally use fedora or ubuntu. So start with making the root user on the database server and then give the root user permissions so that when the application server tries to contact the database server it can easily get through.

Okay now, what you need next is configuring your application server now. If you have used connection pooling, just give the ip of the server you have made as ur database server and never forget to give the exception of the port used in the firewall settings otherwise u will keep trying and u wud never get a response.

So, configured you application server and gave permissions to the root user with the ip of application server. Then you are all set to feel the experience of load distribution.

some command to create user on the database server and giving permission: (MYSQL 5.1 specific commands)

1) update mysql.user set password=password('newpassword') where user='root';
2) create user 'root'@'ipaddress' identified by 'password';
3) grant all on database.table to 'root'@'ipaddress' identified by 'password';
4) configure your application server for your database server's ip address and you are all set to start your application having a database server on the remote system.

happy splitting!!!!

Sunday, August 23, 2009

Web application development in Struts

Well the project that I have discussed in the last post is made in Struts framework. This framework provides a very easy access of the values that the user provides in the UI components. The components are handled by FormBeans and ActionBeans.

for example:

make a login page having UI components as follows:
1) a text box for username
2) a text box for password
3) a login button

Now, just simply make a form bean having the setter and getter functions of all the component properties. Then make a LoginActionBean through which all the form values are accessed and are manipulated as per the requirements and then stored in the database or any other database interaction that the developer wants to have.

The entries of the beans both form and action beans are to be made in the struts-config.xml file of the configuration file of struts. This is the controller where every request comes.

Saturday, August 22, 2009

Session Management in Web Application Development

Session management is one of the most important aspect of web application development. I understood the importance of session management when I was working on my recent project, quiz engine.

The key points for session management are:
1) Whenever a browser is opened, only one session will be created for every tab of the browser.(I tried it for mozilla firefox).

2) Until and unless you close the browser or invalidate the session through Session's invalidate() method, the same session will be used.

3) If your application has a login page through which a user or administrator logs in then you should provide all the information in the session's attribute.

the Session object has lots of functions through which session management can be done.
Example:

String getId() : This method returns an id for the session created.

Long getLastAccessedTime() : This method tells us the time in milliseconds which have passed since 1970 (I was amazed to know this fact!!) to the last time the current session was accessed.

Long getCreationTime() : Returns the number of milliseconds passed since 1970 to the time when the session was created.

I used these methods and setAttribute() and getAttribute() methods quite often in my project and this was very helpful. Through this every user had his own session attributes having different values and the project was running very smooth. When the user ends the quiz I invalidated the session. Thus he couldnt go back from the browser's back button and change the answers once his time was over or he ended the quiz.