Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Alternative banners displaying

 
Gadi Reddy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
How are you?
i need to display the Alternative flash banners in the website.
first time it opens one flash banner, when i refresh it will show another banner.Please help me java code/javascript.

Regards,
Gadi.
 
Travis Hein
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This could be possible using a session attribute.
so that the first time the page is loaded, and the HTTP session that gets created would not contain any custom attributes your app would stuff on it.
So you can look for / set a session attribute that can be used to render the output for the first page load, or different content there after

in the JSP:



Note that by using a date as the object for the first visit within this session, it could be used by something else in your app, like to show different content as the user continues to reload the page over time , during the span of their session.
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have one more idea !
you can use Jsp init parameter in web.xml like

suppose there are five different images, and we can choose randomly 5 images on each request
<!-- Init parameters for the JSP readInitParamJSP -->
<servlet>
<servlet-name>readInitParamJSP</servlet-name> <jsp-file>/web/readInitParamJSP.jsp</jsp-file>
<init-param>
<param-name>1</param-name>
<param-value>path to image 1</param-value>
</init-param>
<init-param>
<param-name>2</param-name>
<param-value>path to image 2</param-value>
</init-param>
and other 3 init parameter for ohter 3 images
</servlet>
<servlet-mapping>
<servlet-name>readInitParamJSP</servlet-name> <url-pattern>/web/readInitParamJSP.jsp</url-pattern>
</servlet-mapping>
</web-app>


............

in jsp you can use following code

<%
int a = (int)(Math.random()*100)/20;
Stirng str= Integer.toString(a);
String parameter =config.getInitParameter(str);

<img src=<%=parameter%> />


i think it should work !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic