aspose file tools*
The moose likes JSP and the fly likes Alternative banners displaying Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Alternative banners displaying" Watch "Alternative banners displaying" New topic
Author

Alternative banners displaying

Gadi Reddy
Greenhorn

Joined: Jan 10, 2006
Posts: 21
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

Joined: Jun 06, 2006
Posts: 161
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.


Error: Keyboard not attached. Press F1 to continue.
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
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 !!!


Thanks and Regards, Amit Taneja
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Alternative banners displaying