Thursday, December 31, 2009

HAPPY NEW YEAR 2010

 


                      I WISH YOU

                                  A

                 HAPPY NEW YEAR
                              2010
                                                  By
                                               Mallik

Tuesday, December 22, 2009

WEB 3.0



The next generation of the web is WEB 3.0 .
The applications will make the user to feel comfortable and easier.


Many of the experts believe that the Web 3.0 browser will act like a personal assistant. In web 3.0 as you search the Web, the browser learns what you are interested in. The more you use the Web, the more your browser learns about you and the less specific you'll need to be with your questions. Eventually you might be able to ask your browser open questions like "where should I go for lunch?" Your browser would consult its records of what you like and dislike, take into account your current location and then suggest a list of restaurants.


The third web 3.0 search engines will take a great revolution in the web. The web 3.0 search engines searches phrases along with the words. This will act like human brain to summarize the results obtained by it.


As you heard the word web 3.0 you may think like what is web 1.0 or what is web 1.0 .


The term web 2.0 is coined by O'Reilly media. After knowing web 2.0 word people used to think about web 1.0 . With out confusion these terms are purely related to the web.


Web1.0 :
Web 1.0 is just like a library from there user can read the information and view the images. For the web 1.0 applications you cannot contribute the information.


Web 2.0:
Web 2.0 allows user to interact with the content on the web and he can share his content on it. The user will get rich experience with web 2.0.


As per the experts the web 3.0 should give every thing by depending on your like and dislikes. As per conversation this might look interesting and it may give good feel to visualize but it will give the headache for the experts while designing and developing.


Julie & JuliaJulie & Julia [Blu-ray] To Wong Foo Thanks for Everything Julie Newmar   The Sound of Music (Two-Disc 40th Anniversary Special Edition)

Monday, December 21, 2009

WEB 2.0



Web 2.0 is commonly used term in the software industry. Most of the people search in the web for this word. Most of the people tries to know about this word. why?


The term Web 2.0 purely related to the web application/Internet applications. As per Wikipedia "A Web 2.0 site allows its users to interact with other users or to change website content, in contrast to non-interactive websites where users are limited to the passive viewing of information that is provided to them".




The web 1.0 applications are the applications which gives information to the user but it won't interact with the user decision. In web 2.0 applications user interacts with the application and he share his decisions, he can own data and he can have control over data .


Web 2.0 sites may have an "Architecture of participation" that encourages users to add value to the application as they use it. Some people calls Web 2.0 as the “participatory Web” and Web 1.0 as “Informatory Web”.

Tuesday, December 15, 2009

Where we need to Store images, in SQL database or in separate folder while development?

These two ways are OK. My suggestion is to store images into sql database if there are no much more images, otherwise, it's better store them into file system because you can store them no matter how many there are.

Advantages of Storing BLOB Data in the Database:

Storing BLOB data in the database offers a number of advantages:
It is easier to keep the BLOB data synchronized with the remaining items in the row.
  1. BLOB data is backed up with the database. Having a single storage system can ease administration.
  2. BLOB data can be accessed through XML support in SQL Server 2005, which can return a base 64–encoded representation of the data in the XML stream.
  3. SQL Server Full Text Search (FTS) operations can be performed against columns that contain fixed or variable-length character (including Unicode) data. You can also perform FTS operations against formatted text-based data contained within image fields—for example, Microsoft Word or Microsoft Excel documents.
Disadvantages of Storing BLOB Data in the Database:
Carefully consider what resources might be better stored on the file system rather than in a database. Good examples are images that are typically referenced via HTTP HREF. This is because:
  1. Retrieving an image from a database incurs significant overhead compared to using the file system.
  2. Disk storage on database SANs is typically more expensive than storage on disks used in Web server farms. 
 Storing Image in a folder:
Storing Image in a folder and using URL or relative path in the database is the way I would recommend. They are having many advantages and here are some of them.
  1. Normally sql server space is more expensive than ordinary disk space in hosting environment.
  2. You can name images in a Search Engine optimized way
  3. Essay to manage, backup and restore images and database.
  4. More suitable for static pages, (if you optimize some pages for performance).

As per my opinion  storing images in the folder is more acceptable.

Saturday, November 7, 2009

Read Image into JSP




In the last post i explained about the reading of image from database to jsp file. This jsp will writes the image as it is in the uploaded size into the jsp. In that case you are fowarding byte array to the jsp and you are writing that byte array in the jsp.
You can also get the image from the database by specifying the action in the src attribute of the image tag as in the below tag.

<img height="600" width="500" src="readImage.do" id="image"/>

In this case the acion will get the byte array of the image from the database and you need to write that byte array into the response as show below....

byte imageArray[] = dao.readImage(imageid);
OutputStream output = response.getOutputStream();
output.write(imageArray);
output.close();

Using output stream you are writing the image array to response this will display the image in the jsp/browser.

In this case you can display the image size as you wish by specifying the height and width.

How to write image into jsp?




WriteIamge.jsp


<%
byte[] imagedata=(byte[])request.getAttribute("imageData");
OutputStream output = null;
if(imagedata!=null){ response.setContentType("image/gif"); try{
output = response.getOutputStream();
output.write(imagedata);
out.clear ();
out = pageContext.pushBody ();
}
catch(Exception e)
{
System.out.println("ERROR OCCURED IN Image jsp");
e.printStackTrace();
}
finally
{
output.flush();
output.close();
}
}else{
out.println("Image not available");
}
%>

How to Upload Image into data base using Spring




Using Multipart Resolver:

To work with images or files with spring you should use the multipart resorver. There are two multipart resolvers in the spring
  •       CommonsMultipartResolver: you need commons-fileupload.jar to work with this resolver.
  •       CosmultipartResolver : You need Cos.jar to work with resolver.
Apart from these jar files add the dependent jar files also into the application.
You can specify the maximum size of the image in the bits with the <property /> tag under the <bean > tag.
<bean id="multipartResolver"class="org.springframework.web.multipart.              commons.CommonsMultipartResolver">
<!-- one of the properties available; the maximum file size in bytes -->
  <property name="maxUploadSize" value="100000"/>
</bean>
                             (or)


<bean id="multipartResolver" class="org.springframework.web.multipart .cos.CosMultipartResolver">
                       <!-- one of the properties available; the maximum file size in bytes -->
                        <property name="maxUploadSize" value="100000"/>
</bean>


uploadfile.jsp:

Create the jsp to upload the image. The form enctype should be 'multipart/form-data' and use the file tag to get the browse option in the page.
<html>
<head>
         <title>Upload a file Example</title>
</head>
<body>
        <h1>Browse a file</h1>
        <form method="post" action="upload.form" name='uploadForm'   enctype="multipart/form-  data">
             <input type="file" name="file"/>
             <input type="submit"/>
         </form>
</body>
</html>


Form Bean:

Write the Bean class for the fileUpload.jsp. You can specify the file data type as MultipartFile or byte or
public class FileUploadBean {
private MultipartFile file;
public void setFile(MultipartFile file) {
this.file = file;
}
public MultipartFile getFile() {
return file;

}
}

FileUploadController.java:

Read the image using the controller class.
public class FileUploadController extends SimpleFormController {
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws ServletException, IOException {
// cast the bean
FileUploadBean bean = (FileUploadBean) command;
MultipartFile file = bean.getFile();
if (file == null) {
System.out.println("Unable to rad the image from Jsp");
}
//While writing it into data base if you want to use in the byte array you can convert it
byte imageArray[] = file.getBytes();
//once you got the byte array you can save it in database get the database connection
//save it in the database


return super.onSubmit(request, response, command, errors);
}
}


Configuring in Dispatcher Servletxml:

<beans>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
               <property name="mappings">
                      <value>
                              /upload.form=fileUploadController
                    </value>
        </property>
</bean>
<bean id="fileUploadController" lass="examples.FileUploadController">
               <property name="commandClass" value="examples.FileUploadBean"/>
               <property name="formView" value="fileuploadform"/>
               <property name="successView" value="confirmation"/>
          </bean>
</beans>

Monday, October 26, 2009

How to get selected text from the dropdown ?


The below function explains how to get selected text of the drop down menu using javascript.


function getSelectedText(){
     var subText = document.getElementById("subject");
     var selectedText = subText.options[subText.selectedIndex].text
     alert(selectedText);
}
"subText.selectedIndex" gives index of the selected value, By passing that index value to array of the subtext options you will get the selected text from the drop down menu.


Monday, October 12, 2009

Java Try catch block


 /**
 *
 */
package com.myapp.testpackage;


/**
 * @author sunil.chand
 *
 */
public class Exc1 {
  public static void main(String args[]){
      int d,a;
      try{
          d=0;
          a=42/d;
          System.out.println("never printed");
      }
      catch (ArithmeticException e){
          System.out.println("Division by zero not possible"); 
      }
            
  }
}

Monday, October 5, 2009

Struts2 Eclipse plugins

               Struts2 is the Java based framework developed by Apache. This is combination of Struts1.x and the webwork.
              I feel, to develop Struts2 based applications using the Eclipse ide is little bit easy and comfortable. So that i searched for the plugins for eclipse ide. Generally you can dump the struts2 jar files in lib folder of the web application and use the struts2 functionalities.
As we know, plug ins provide the extra functionality in the development.
These are the two links which i felt food.


and



find the installation procedure,  license and terms and conditions over the sites and enjoy the development of Struts 2 applications.


All the best.............