Showing posts with label examples in css. Show all posts
Showing posts with label examples in css. Show all posts

January 28, 2015

Java Spring MVC hello World Example in Eclipse


Java Spring Model View Controller Hello World Example in Eclipse


Description : In this post we are sharing only source code for java spring application, For theoretical note you can refer this site I could nt provide a better description on java spring than this. Please note the deployment descriptor (web.xml) where we had provide the name index.jsp as our welcome file.

index page (index.jsp)

<html>
<head>
 <title>Office Management System</title>
</head>
<body>
<a href="hello.html">Click here</a>
</body>
</html>

Deployment Descriptor (web.xml)

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <display-name>CfedOMS</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
 <servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>
</web-app>


spring-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">
       <context:component-scan base-package="net.cfed.oms.controller" />
   <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>
</beans>

JSTL (Java Standard Tag Library) : Expression Language ( EL) makes it possible to easy access application data stored in java bean.
Format : ${expression}

hello.jsp

<html>
<head> <title> This is my First application in Java Spring MVC </title></head>
<body>  ${message} </body>
</html>

What and Why annotation in java ?
Annotation allows implemented class to be auto-detected during class path spanning.
format : @component

RequestMapping is most used annotation method in java spring. It is used to map web request to a specific handler method. Here ModelAndViewHelloWorld Method. This concept is similar to java jsp servlets

Controller it indicates that the annotated class is a controller i e a web controller. 

HelloworldController.java

package net.cfed.oms.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HelloWorldController {

    @RequestMapping("/hello")
    public ModelAndView helloWorld() {
        String message = "Hello, This is my first sample spring MVC project !";
        System.out.println(message);
        return new ModelAndView("hello", "message", message);
    }

}


Project structure


Why should i choose java spring ?
Once you configured java spring, you can easily work on the business logic of your application.

http://javabelazy.blogspot.in/

February 15, 2014

Image slidder using javascript


Created an image slidder in java web using java script

+bithesh soubhagya


This is a small example in javascript that helps you images in specific intervals as like jquery slidder. The code is simple to understand.


The html page (copy paste this code and save as .html file)
place the images in images folder(rename the image files either in your code or the images you are placing)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title> Image slidder using javascript </title>
<script src="js/jquery-1.9.0.js"></script>
<script src="js/jquery.min.js"></script>


<script>

var images = [
              'images/1.jpg',
              'images/2.jpg',
              'images/3.jpg',
              'images/4.jpg',
              'images/5.jpg',
              'images/6.jpg',
             
          ];
         
    
for(var i=0;i<=3;i++)
{
    var myVar=setInterval(function(){myTimer()},1000);
}

var j=0;

function myTimer()
{
    document.getElementById("mahashi").innerHTML ="";
    //adding image to div using javascript
    var elem = document.createElement("img"); // create a elem variable for tag <img>
    elem.setAttribute("src", images[j]);      // setting img attribute to elem variable
    elem.setAttribute("alt", "Flower"+j);
    document.getElementById("slider").appendChild(elem);
    $("img").fadeIn();  // animation for img tag
    j = j+1;
    if(j>5){
        j=0;
    }
}

</script>

</head>
<body>
<h1> HTML java script example for image slidding </h1>

<div id="mahashi">

</div>

</body>
</html>

You can download the latest version of jquery plugin from here


http://belazy.blog.com/

August 21, 2012

To call external css class using jquery

How to call an external css class using jquery.

There are two ways to apply css through jquery

addClass("your css class name");

addClass will only append the new class to the existing one. so we have to remove the existing class using removeClass(" your css class name") method.

removeClass() is used to remove all the css class.

css() is used to apply style to a specific html component.

How to ?

html : file.html
<p id="powerballNumbers"> Hunger Games, Newsweek, </p>
<div id ="RioDeJaneiro" class ="McllroyClass"></div>

jquery : file.js
$("#powerballNumbers").css({"background":"yellow"});
$("#RioDeJaneiro").removeClass("McllroyClass").addClass("rihana");

css: file.css
.rihana
{
width : 10px;
height : 5 px;
backgroud : url (img_mileycyrus.gif) 0 0;
}

How to create a web application with jquery :  a simple web application

http://belazy.blog.com/

Facebook comments