Simple GIS

GISプログラムの練習

bean

package car;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;

import javax.servlet.http.HttpSession;

public class pro extends HttpServlet {

   
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {

            String file,str,strx;
            String data=new String[50000];
            String artist=new String[50000];
 String title=new String[50000];
            int s,datanumber;
int p1,p2;            
int year=new int[9000];
int month=new int[9000];
int day=new int[9000];

            ServletContext context = this.getServletContext();
            
            file=context.getRealPath("mj2.txt");
            
            
               HttpSession session = request.getSession();
           bean cc = (bean) session.getAttribute("buta");
      
            
            
            
            file sub=new file();
            sub.makedata(file);
            data=sub.data;
            datanumber=sub.datanumber;
            
            for(s=2;s<datanumber+1;s++){
            str=data[s];
            p1=str.indexOf("");
            p1=str.indexOf(">",p1);
            p2=str.indexOf("");
            artist[s-1]=str.substring(p1+1,p2);
            p1=str.indexOf("
");
            p1=str.indexOf(">",p1);
            p2=str.indexOf("

");
            title[s-1]=str.substring(p1+1,p2);
            p1=str.indexOf("");
            p1=str.indexOf(">",p1);
            p2=str.indexOf("");
            strx=str.substring(p1+1,p2);
            year[s-1]=Integer.parseInt(strx);
             p1=str.indexOf("");
            p1=str.indexOf(">",p1);
            p2=str.indexOf("");
            strx=str.substring(p1+1,p2);
            month[s-1]=Integer.parseInt(strx);
             p1=str.indexOf("");
            p1=str.indexOf(">",p1);
            p2=str.indexOf("");
            strx=str.substring(p1+1,p2);
            day[s-1]=Integer.parseInt(strx);
            }
      
            
          cc.setartistnumber(datanumber-1);
          cc.setartist(artist);
          cc.setday(day);
          cc.setmonth(month);
          cc.setyear(year);
          cc.settitle(title);
          
          
            
            
           
        } finally {            
            out.close();
        }
    }

    // 
    /**
     * Handles the HTTP
     * GET method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP
     * POST method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// 
}