Ask for JSP problem, can run on a computer, can't run on another platform?

Source: Internet
Author: User

Package Com.mvc;import Java.io.ioexception;import javax.servlet.requestdispatcher;import Javax.servlet.servletexception;import Javax.servlet.http.httpservlet;import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.HttpServletResponse; Public classExample6_1 extends HttpServlet {/**     *      */    Private StaticFinalLongSerialversionuid =1L; @Override Public voiddoget (httpservletrequest request, httpservletresponse response) throws Servletexception, IOException { //TODO auto-generated Method StubModel data =NewModel ();//Create a JavaBean objectRequest.setattribute ("Data", data); String Shouxiang= Request.getparameter ("a"); intA =Integer.parseint (Shouxiang);        Data.seta (a); String Xiangshu= Request.getparameter ("N"); intn =Integer.parseint (Xiangshu);        DATA.SETN (n); String Gong= Request.getparameter ("Q"); intQ =integer.parseint (gong);        DATA.SETQ (q); Data.setname ("tolerance of arithmetic progression"); intsum =0;  for(inti =0; I < n; i++) {sum+=A; A+=Q;        } data.setsum (sum); RequestDispatcher Dispatcher= Request.getrequestdispatcher ("show.jsp");    Dispatcher.forward (request, response); } @Override Public voidDoPost (httpservletrequest request, httpservletresponse response) throws Servletexception, IOException { //TODO auto-generated Method StubModel data =NewModel ();//Create a JavaBean objectRequest.setcharacterencoding ("iso-8859-1"); Request.setattribute ("Data", data); String Shouxiang= Request.getparameter ("a"); intA =Integer.parseint (Shouxiang);        Data.seta (a); String Xiangshu= Request.getparameter ("N"); intn =Integer.parseint (Xiangshu);        DATA.SETN (n); String Gong= Request.getparameter ("Q"); intQ =integer.parseint (gong);        DATA.SETQ (q); Data.setname ("tolerance of geometric series"); intsum =1;  for(inti =0; I < n; i++) {sum+=A; A*=Q;        } data.setsum (sum); RequestDispatcher Dispatcher= Request.getrequestdispatcher ("show.jsp");    Dispatcher.forward (request, response); }}package Com.mvc; Public classModel {intA; intN; intQ; intsum; String name="";  PublicString GetName () {returnname; }     Public voidsetName (String name) { This. Name =name; }     Public intgetsum () {returnsum; }     Public voidSetsum (intsum) {         This. sum =sum; }     Public intGeta () {returnA; }     Public voidSetA (inta) { This. A =A; }     Public intGetn () {returnN; }     Public voidSETN (intN) { This. N =N; }     Public intGetQ () {returnQ; }     Public voidSETQ (intq) { This. Q =Q; }}<?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"><servlet><servlet-name>hhh</servlet-name><servlet-class>com.mvc.example6_1</servlet-class></servlet><servlet-mapping> <servlet-name>hhh</servlet-name> <url-pattern>/heh </url-pattern></servlet-mapping></web-app> <%@ Page contenttype="text/html; charset=gb2312"%>"show.jsp"Method="Get">arithmetic progression summation:<br> Enter the first <input type="text"Name="a">Input Tolerances:<input type="text"Name="Q">Sum of items:<input type="text"Name="N"> <input type="Submit"Value="Submit"> </form> <form action="heh"Method="Post">Geometric series summation:<br> Enter the first <input type="text"Name="a">input male ratio:<input type="text"Name="Q">Sum of items:<input type="text"Name="N"> <input type="Submit"Value="Submit"> </form></body>"text/html; charset=gb2312"%><jsp:usebean id="Data" class="Com.mvc.model"Scope="Request"></jsp:usebean><table border="1"> <tr> <th> First item of the series </th> <th><jsp:getproperty property="name"Name="Data"/></th> <th> number of items </th> <th> summation results </th> </tr> <tr> &lt ; Td><jsp:getproperty property="a"Name="Data"/></td> <td><jsp:getproperty property="name"Name="Data"/></td> <td><jsp:getproperty property="N"Name="Data"/></td> <td><jsp:getproperty property="sum"Name="Data"/></td> </tr></table>

Ask for JSP problem, can run on a computer, can't run on another platform?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.