Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JSP Interest »

Re: Determin the RAM(memory) on the user's system

Ananthalakshmi Subramaniyam

2004-07-12


On Thu, 1 Apr 2004 21:43:47 -0700, Vinay <vinaygutta@(protected):

>Hi,
>
> I want to determine the RAM(memory) on the user's system, and then
>display the appropriate web page to the user. I just want to know how to
>do it with JSP.
>
> Can anyone help me out?
>
>Vinay
>
> ==========================================================================
>To unsubscribe: mailto listserv@(protected)-
INTEREST".
>For digest: mailto listserv@(protected)
DIGEST".
>
>Some relevant archives, FAQs and Forums on JSPs can be found at:
>
> http://java.sun.com/products/jsp
> http://archives.java.sun.com/jsp-interest.html
> http://forums.java.sun.com
> http://www.jspinsider.com

There are methods available in java.lang.Runtime class to get memory
details.

Sample snippet:

<%
Runtime rt = Runtime.getRuntime();
long totalMemory = rt.totalMemory();
System.out.println("Total memory allocated to VM: " + rt.totalMemory());
System.out.println("Memory currently available: " + rt.freeMemory());
%>

based on the total memory, forward the user to appropriate page.

For ex,

<%
if(totalMemory <= size1) {
%>
<jsp:forward page="page1.jsp"/>
<%} else if(totalMemory <= size2){
%>
<jsp:forward page="page2.jsp"/>
<%}%>

You may want to check free Memory to forward instead of total memory.

===========================================================================
To unsubscribe: mailto listserv@(protected)".
For digest: mailto listserv@(protected)".

Some relevant archives, FAQs and Forums on JSPs can be found at:

http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com
©2008 junlu.com - Jax Systems, LLC, U.S.A.