package com.knowledgewalls; import org.springframework.stereotype.Component; @Component public class RndHolder { private int rndNumber; public int getRndNumber(){ return rndNumber; } public void setRndNumber(int rndNumber){ this.rndNumber = rndNumber; } public void generateRndNumber(){ this.rndNumber = (int) (Math.random() * 99999); } }
package com.knowledgewalls; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.context.ApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @WebServlet("/ShowAccountDetails") public class ShowAccountDetails extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(req.getServletContext()); RndHolder rndHolder = (RndHolder) context.getBean("rndHolder"); rndHolder.generateRndNumber(); resp.getWriter().write("Rnd Number: "+rndHolder.getRndNumber()); } }
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:component-scan base-package="com.knowledgewalls" /> </beans>
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>RequestScopeExample</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> </welcome-file-list> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/beans-servlet.xml </param-value> </context-param> </web-app>
Do you want to delete a "" lesson. Warning! This delete will remove all it's sub lessons and contents.
Do you want to delete a "" sub lesson. Warning! This delete will remove all it's contents.
Do you want to delete content.
Do you want to remove selected book from favorite books.
Do you want to delete selected author from your authors list.