Skip to main content

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

Popular posts from this blog

JSP Comments

Comments in JSP:- -->Compiler /Interpreter doesn't take commented code for compilation /Interpretation, so the commented code doesn't participate in execution JSP supports 3 types of comments:- a.)HTML comments /Template text comments/ Output comments Syn :- <!---text---> -->Recognized by html interpreter of browser b.)JSP comments /Hidden comments Syn :- <%--text--%> -->JSP page compiler recognize these comments c.)Java comments /Scripting comments Syn :- //-->For single line /*-- -----*/-->For multiple line -->Java compiler(java) recognize these comments -->In Eclipse IDE JES class for first.jsp comes in our(workspace)folder/.metadata/.plugins/.org eclipse Comments (1)JSP comment<%--%> (2)Java comment(// or /*--*/) (3)HTML comments(<!---> JES Source Code (1)No (2)Yes (3)Yes In JES compiled code (1)No (2)No (3)Yes In the code going to browser (1)No (2)No (3)Yes Output (1)No (2)No (3)No -->Jsp comments are not visible in any phase

Scripting Tags

JSP Tags/ Elements (1)Scriptlet     Standard syn:-         <%.........%>     xml syn:-        <jsp:scriptlet>...</jsp:scriptlet> Note: All scripting tags allows us to place script code(java code) 1.)The code placed in scriptlet go to _jspService(-,-) of JES class 2.)In a jsp page we can have zero or more scriptlets 3.)We place request processing logics in scriptlets 4.)Variables declared in scriptlets becomes the local variables in _jspService(-,-) of JES class in first.jsp In first.jsp: <% int a=10;  out.println("square:"+(a*a));%> In first_jsp.java(JES): public class first_jsp extends..{     public void _jspService(-,-){        int t=30;        out.println(“Square:”+(t*t));     }  } The code placed in scriptlet can use implicit objects of jsp because implicit objects and the code placed scriptlet goes to _jspService(-,-) method of JES class first.jsp Browser s/w name: <%out.println(request.getHeader("user-agent");%> first_jsp.java pu

Project Architecture's

1.) Functional flow/ Architecture a.) Only for 6+/7+years b.) Explain the flow of process/business 2.) Technical Flow/Architecture a.) Upto 5+ years b.) Explain technologies /components that are involved in the project Servlet & JSP Project Architecture:- 1.)What is need of Business Deligate to convert VO class object to DTO class object ? a.) If Business Deligate is not there servlet component directly prepares DTO class object by receiving and translating form data and passes to service class, if service class excepts certain input in other format like numeric employee number as string employee number then we need to modify servlet component code i.e For the changes that happened in business tier service component we have to modify servlet component of presentation tier b.) If Business Deligate is taken then it gets original form data as VO class object having string inputs and converts VO class object to DTO class object to pass to service class c.) If service class excepts