Javabean automatically to the source
Abstract: javabean automatically to the source
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="338" height="86" align="left" valign="top">
Following is the source java
ReturnTo.java
Package examples;
Import java.io. *;
Import java.util .*;
Import javax.servlet .*;
Import javax.servlet.http .*;
/ *
Automatic steering javabean
* /
Public class ReturnTo extends HttpServlet
(
Private String Msg;
Private String Rurl;
Private boolean isA;
Public void setMsg (String inMsg) (
This.Msg = inMsg;
)
Public void setRurl (String inRurl) (
This.Rurl = inRurl;
)
Public void setIsA (boolean inisA) (
This.isA = inisA;
)
Public String getMsg () (
Return this.Msg;
)
Public String getRurl () (
Return this.Rurl;
)
Public boolean getIsA () (
Return this.isA;
)
Public void go (HttpServletResponse response) throws IOException, ServletException (
PrintWriter out = response.getWriter ();
Out.print ( "<script language='javascript'>");
If (this.isA) (
Out.print ( "alert ( '" + + "!');"); Msg
)
Out.print ( "location.href = '" + Rurl +"';");
Out.print ( "</ script>");
)
)
Application test.jsp
<% @ Page contentType = "text / html; GBK charset ="%>
<%
String Msg = "automatic shift in ….";
String Url = "http://www.java3z.com";
We.setMsg (Msg);
We.setRurl (Url);
We.setIsA (true);
We.go (response);
%>
Notes:
1: Save the file position
ReturnTo.class ===> web-inf/classes/examples /
Test.jsp arbitrary position
2, wrote this page is not too many of javascript code:) simply frivolous.
3, in testing jdk1.5 tomcat + + win2k3 through.
</ Td> </ tr> <tr> ↑ Back
Tags: javabean, out source, source






