Friday, 12 August 2011

HTML:- Get Browser Closed Event

Getting the browser closed event ,before close we can get the event and do something.I need this This is needed when needed to set the session null or the session should be destoryed after closed the browser.By this we can achive that...........

script type="text/javascript"

function closeEditorWarning()


return 'Hey, What r u Doing ? Are you sure?'


window.onbeforeunload = closeEditorWarning;

Thursday, 11 August 2011

Java :- How to Logout/Signout in Java

Logout In Java (JSP/SERVLET)

Many Questions..

how to disable back button of the browser after logout?

Many Problems & questions I found when related to logout/signout .After signout/logout the browser

Back button is working and a user can go inside or previous page without again login.Once you logout/signout ,i.e. you cannot go to your working page without once again new login.But , there was

a problem after Logout/Signout the Back button is working.To avoid this for implementing proper logout/signout I solve this....


1. set the Session to Null (Do not invalidate the session if the jsp use other session including Login)


2. Set the necessary Header to Every Jsp having Logout/Signout Link

//Forces caches to obtain a new copy of the page from the origin server

response.setHeader("Cache-Control", "no-cache");

//Directs caches not to store the page under any circumstance

response.setHeader("Cache-Control", "no-store");

//Causes the proxy cache to see the page as "state"

response.setDateHeader("Expires", 0);

//HTTP 1.0 backward compatibility

response.setHeader("Pragma", "no-cache");

3. Check the session (Username) in jsp ,if null the redirect to Login Page.



}catch(Exception ex){}



//Do normal }

Now it will work . Enjoy and Follow Me.

Wednesday, 10 August 2011

Manoj.Blog: Java :- Sending Data to Servlet From JSP

Manoj.Blog: Java :- Sending Data to Servlet From JSP

Java :- Sending Data to Servlet From JSP

Sending Data from Jsp to Servlet or Communication between Jsp & Servlet , we need certain things like ;-

1. A Jsp File

2. Deployment Descriptor (web.xml)

3. A Servlet File (Normal Java File)

Jsp File (index.jsp)

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>


String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";


My JSP 'index.jsp' starting page

Servlet File (

Note : Here doGet/doPost/service method can be used.But I used here doGet(),becacuse the form action method is GET in index.jsp. So , I used doGet() in this example. But service method can use for both POST/GET method .But you can use any of these.

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {


PrintWriter out = response.getWriter();

String name=request.getParameter("txtname");




out.println(" A Servlet");


Hi I am





out.println(" ");





Deployment Descriptor (Web.xml)


This is the description of my J2EE component

This is the display name of my J2EE component





Note: In web.xml url-pattern is the path for browser ,so any name can be used (not /test1). we need & tag for run & map a servlet to the path. But, Url-pattern must match with the form action .

This is a simple Example for Communicate a servlet from jsp by passing a value Name or any Data.Enjoy..............the flavor of JAVA.

Posted By:- javadevelopersguide

Follow :-

Java :- Setting Heap Size in Eclipse / My Eclipse

Error Jvm Heap Size (On Eclipse / My Eclipse)

I have set this feature in my IDE. I got this type of error when my team is on the project social network type project in struts framework.I was really in trouble , and seeking a solution finally I got the solution.It help U.

Heap memory related error java.lang.OutOfMemoryError.
What needs to be done here basically is to increase the jvm heap size. So for increasing the JVM Heap Size of Tomcat in Eclipse we have to set few VM arguments of the tomcat.
Follow the simple steps to change the Heap Size of Tomcat under Eclipse.
1. Open the Server tab in Eclipse and double click the Tomcat server to open Server Configuration.
2. In Server Configuration, click on the Launch Configuration link under General Information.
3. Under Arguments tab, add following values in VM arguments.
-Xms64m -Xmx256m

Java :- Heap Size Error (JAVA )

//What is JVM Heap Size? How does it affect the performance of the Application?

//Error java.lang.OutOfMemoryError: Java heap space


Some times there may be no space for running the java program.At that time

programmer should increase the size of Heap area of JVM or Web Server.

For Increase the heap Size:

For a Run a Java Program Run with:- java -Xms65m -Xmx512 yourJavaFile

For run with Tomcat set the Environment Variable :- set JAVA_OPTS="-Xms256m -Xmx1024m"


-Xms is the initial Java heap size

-Xmx is the maximum Java heap size

-Xss is the java thread stack size