1. you can use: response.sendRedirect(www.foo.compatherror.html); 2. you can manually modify the Location attribute of HTTPheader as follows: <% response; response. setHeader ( 1. you can use:
Response. sendRedirect ("http://www.foo.com/path/error.html "); |
2. you can manually modify the Location attribute of the HTTP header as follows:
<% Response. setStatus (HttpServletResponse. SC _MOVED_PERMANENTLY ); String newLocn = "/newpath/index.html "; Response. setHeader ("Location", newLocn ); %> |
3. you can also use forward:
<Jsp: forward page = "/newpage. jsp"/> |
Note: This method can only be used before any output is sent to the client.
5.6 practices similar to global. asa
There is no global. asa counterpart in JSP. However, there can be a workaround to run. For example, if you need to store or access the application scope variable, you can always create a Javabean and include it where the variables are needed on the page.
<Jsp: useBean id = "globals" scope = "application" class = "com. xxx. GlobalBean"/> |
However, some products have the following features:
Allaire's product JRun 3.0 will provide global. jsa. JRun 2.3.3 is still supported, but only JSP 0.92 is supported. When JRun 3.0 is finally launched, it will support global. jsa for JSP 1.0 and 1.1.
You can get JRun 3.0 beta 5 from http://beta.allaire.com/jrun30.
In addition, Oracle JSP supports globals. jsa.
5.7 jsp display current time
<% @ Page import = "Java. util. *, Java. text. *" %> <HTML> <HEAD> <TITLE> JSP to display the current time </TITLE> </HEAD> <BODY> The current time is: <% Date now = new Date (); Out. println (DateFormat. getTimeInstance (). format (now )); %> </BODY> </HTML> |
5.8 create the directory Mkdir (String path) in JSP)
<% @ Page import = "Java. io. *" %> <%! String Mkdir (String path) { String msg = null; |