In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to test a JSP container. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Because the example given above is complicated. It's hard for most people to understand. I am also ^ _ ^, but if I look at it carefully, I will write a relatively simple one myself. I hope you will discuss it together. JSP container being tested
${name}
${pass}
Ant puts it directly in the root directory of the eclipes project, build.xml, but has three parameters to set the address of tomcat.home Tomcat, the root directory of the webapp.path project, and the WEB-INFsrc source code below (then JSP will be translated into .java to the org.apache.JSP.JSP of this directory)
TEST
Package jetty.test.supper; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.jsp.jsp.MyJsp_jsp; import com.meterware.httpunit.GetMethodWebRequest; import com.meterware.httpunit.WebRequest; import com.meterware.httpunit.WebResponse; import com.meterware.servletunit.InvocationContext; import com.meterware.servletunit.ServletRunner; import com.meterware.servletunit.ServletUnitClient; import junit.framework.TestCase; public class JSPCTest extends TestCase {private InvocationContext ic = null Protected void setUp () throws Exception {ServletRunner sr = new ServletRunner (); / / register jsp sr.registerServlet ("HelloWorld", MyJsp_jsp.class.getName ()); ServletUnitClient sc = sr.newClient (); WebRequest request = new GetMethodWebRequest ("http://localhost/HelloWorld"); ic = sc.newInvocation (request);} public void testJspC () throws Exception {HttpServletRequest re = ic .getRequest (); HttpServletResponse rq = ic.getResponse () Re.setAttribute ("name", "liukaiyi"); re.setAttribute ("pass", "123456"); MyJsp_jsp is = (MyJsp_jsp) ic.getServlet (); is._jspService (re,rq); WebResponse response = ic.getServletResponse (); / / output System.out.println (response.getText ());}}
As a result,
Liukaiyi
123456
Thank you for reading! This is the end of the article on "how to test the JSP container". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.