AdvertisementRotator

Add Rotator App(AdvertisementRotator):
1.)Add should come as graphical hyper link
2.)Add should come randomly
3.)Add should be changed at regular intervals
4.)Follow mvc1 architecture (jsp with java class /java bean)

AddRotatorApp

  1. |-->java resources
  2.      |-->src
  3.          |-->xyz.bean
  4.               |-->Rotator.java
  5. |-->webcontent
  6.      |-->addrotator.jsp
  7.      |-->1.png, 2.png, 3.png, 4.png, 5.png
  8.      |-->WEB-INF
  9.          |-->web.xml

Rotator.java

  1. package xyz.bean;

  2. import java.util.Random;

  3. public class Rotator {
  4. int addNo;
  5.   private String images[] = { "1.png", "2.png", "3.png", "4.png", "5.png" };
  6.   private String links[] = { "http://www.raymond.in", "http://onlyvimal.co.in",      "https://www.peterengland.com",
  7. "http://www.siyaram.com", "https://www.ramrajcotton.in" };

  8.    public void nextAdd() {
  9.       Random rad = null;
  10.       rad = new Random();
  11.       addNo = rad.nextInt(5);
  12.    }

  13.    public String getImage() {
  14.       return images[addNo];
  15.    }

  16.    public String getLink() {
  17.      return links[addNo];
  18.    }
  19. }//class

addrotator.jsp


  1. <!-- Create or locate Java Bean -->
  2. <jsp:useBean id="rotator"  class="xyz.Rotator" scope="session"/>

  3.    <% rotator.nextAdd();
  4.         response.addHeader("refresh","2");
  5.     %>
  6. //Display Add as Graphical hyperlink
  7.   <a href="<jsp:getProperty name="rotator" property="link"/>"> 
  8.       <img src="<jsp:getProperty name="rotator" property="image"/>" width="500"        height="200">
  9.   </a>

web.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  3.   <display-name>AdvertisementRotator</display-name>
  4.      <welcome-file-list>
  5.        <welcome-file>index.html</welcome-file>
  6.        <welcome-file>index.htm</welcome-file>
  7.        <welcome-file>index.jsp</welcome-file>
  8.        <welcome-file>default.html</welcome-file>
  9.        <welcome-file>default.html</welcome-file>
  10.        <welcome-file>default.jsp</welcome-file>
  11.      </welcome-file-list>
  12. </web-app>

Comments

  1. thanks bro..but from which blog we can find source code??

    ReplyDelete
    Replies
    1. Hey hi Pradip.. , We have Nataraz sir code which we was collected from his website(http://www.nataraz.in/software/). Due to some works we didn't focused on codes but we'll add all examples codes in future, but for sake of you we'll post AdvertisementRotator example within 20min..

      Thanks..!

      Delete
  2. This comment has been removed by the author.

    ReplyDelete

Post a Comment

Express your feelings

Popular posts from this blog

Project Architecture's

JSP Life Cycle