AD

Visit the web element (3) - Get real type - dependent on container

package com.zchen.struts2.user.action;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction3 extends ActionSupport {
        
        private HttpServletRequest request;
        private HttpSession session;
        private ServletContext application;
        
        public LoginAction3() {
                request = ServletActionContext.getRequest();
                session = request.getSession();
                application = session.getServletContext();
        }
        
        public String execute() {
                request.setAttribute("r1", "r1");
                session.setAttribute("s1", "s1");
                application.setAttribute("a1", "a1");
                return SUCCESS; 
        }
        
}


<form name="f" action="" method="post">
 User name  :<input type="text" name="name"/>
 Password  :<input type="text" name="password"/>
<br />
<input type="button" value="submit1" />
<input type="button" value="submit2" />
<input type="button" value="submit3" />
<input type="button" value="submit4" />
</form>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "**struts.apache**/dtds/struts-2.0.dtd">

<struts>
    <constant name="struts.devMode" value="true" />
    <package name="login" extends="struts-default" namespace="/login">
        <action name="login*">
            <result>/user_login_success.jsp</result>
        </action>
    </package>
</struts>
标签: public string, opensymphony, lt xml, utf 8, import org, doctype, jsp, action gt, type button, input type text, struts apache, dtds, httpservletrequest request, lt package, return success, httpsession, apache software foundation, session request, default namespace, web element
分类: Java
时间: 2010-11-30

相关文章

  1. Visit the web elements (1) - Get Map type - dependent container

    package com.zchen.struts2.user.action; import java.util.Map; import com.opensymphony.xwork2.ActionContext; imp ...
  2. Packaged class, visit the web page using httpClient.

    Done several projects httpclient visit, I can use to publish a class for your reference it; hope to help peopl ...
  3. java httpClient4.0 visit the Web site through a proxy authentication

    httpClient4.0 visit through a proxy authentication import java.io.IOException; import org.apache.http.HttpEnti ...
  4. Failure or visit a Web page dialog box pop-up download index.htm

    Visit the download page index.htm failure or the dialog box pops up, or save the other things The solution: Bu ...
  5. Visit the Web site using google translation

    Today inadvertently use google translation, enter the http:// at the beginning of the URL, found to have a spe ...
  6. visit the Web site in the port configuration lighttpd2.0.4

    Download the latest version of lighttpd, and then configure and found not the same as the original. 1.lighttpd ...
  7. struts2 those things (visit the web elements)

    debug: value stack contents (The stuff inside is a direct take) stack Context (The stuff inside is taking with ...
  8. Visit the web elements (2) - Get Map type-Ioc

    package com.zchen.struts2.user.action; import java.util.Map; import org.apache.struts2.interceptor.Application ...
  9. Visit the web elements (4) - Get Real Type-Ioc

    package com.zchen.struts2.user.action; import javax.servlet.ServletContext; import javax.servlet.http.HttpServ ...
  10. Struts2.1 Study Notes _03

    struts2.1 of the Chinese processing <br /> adding constants in struts.xml configuration: <content nam ...
  11. (Transfer) client to access Web Service - the parameter type of serialization and deserialization (b)

    This is the Client Access Web Service - the parameter type of serialization and deserialization (a) the subseq ...
  12. web.xml, listener, filter, Servlet load order

    In the project will always encounter some problems on the priority of loading, also recently encountered a sim ...
  13. Tomcat web.xml file in the details

    Tomcat web.xml file in the details <? Xml version = "1.0" encoding = "GB2312"?> < ...
  14. Switch to using the WSE Web Service Security ---- I realize the first

    WSE (Web Services Enhancements) is to enable developers by Microsoft. NET to create a more powerful and easier ...
  15. web.xml in the listener. filter.servlet loading order and Xiang Jie (2)

    In the project will always encounter some problems on the priority of loading, also recently encountered a sim ...
  16. Filter (filter) in the web application

    Filter (Filter) in the Web development application: Filter specification from the beginning Servlet2.3 new fea ...
  17. Asp.net - web.config Xiangjie (change)

    application ("dsn") = "server = moon; driver = sql server; database = store; uid = user; pwd = ...
  18. web.xmlweb.xml configuration Xiangjie

    Web.xml common elements <web-app> <display-name> </ display-name> defines the name of WEB ap ...
  19. struts-config.xml file description element

    Struts application uses two XML-based configuration files to configure, namely web.xml and struts-cofig.xml fi ...