0

I am doing an OCR system where user can upload an image of any format. then the uploaded image is displayed inside the imageView.jsp page. imageView.jsp

<div  id = "imageView" class="col-lg-8 center-block modal-content">
                    <form action="ImagePreprocess" method="post" class=" form" role="form" enctype="multipart/form-data">
                        <input type="submit" class= "btn btn-image pull-left" value="OCR">
                    </form>

                    <a href="home.jsp" class="btn btn-default bg-light-gray">Upload a new Image</a>

                </div>

            </div>
            <%
                String fname = (String) request.getAttribute("name");
            session.setAttribute("filename ", fname);
                fname = fname + ".jpg";
                String fnames = (String) request.getAttribute("images");
                request.getSession().setAttribute("bimla", fnames);
                System.out.println("fnames:"+fnames);
                System.out.print("uploaded image bbbbbbb"+fname);
                String path = "";
                if (request.getAttribute("name") != null) {
                    path = request.getAttribute("name").toString();
                }
              //  String filepath = application.getRealPath("/uploadedImage/");
               // System.out.println(filepath);


            %>

            <div class="row">
                <div  id = "display" class="col-lg-8 center-block modal-content">
                <img src='uploadedImage/<%=fname %>'width="600" height="400"/>
                   <input type="hidden" name="image" value="<%=fname %>" />
                </div>

imagePreprocess.jsp

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

            //System.out.println("bimla1");
            PrintWriter out = response.getWriter();
          HttpSession fileNameSession = request.getSession();
          //  String imageName = (String) fileNameSession.getAttribute("filename");
          //  String imageName = (String)request.getAttribute("filename");
         // String imageName =  (String) request.getSession().setAttribute("filename");
         //   System.out.println("i am bimlaaaaa"+imageName);

            //System.out.println("bimla2");
           String imageName = request.getParameter("image").toString();
          // String imageName =(String) fileNameSession.getAttribute("bimla");

            //System.out.println("bimla3");
            grayscaleClass grayImage = new grayscaleClass();

            //System.out.println("bimla4");
            imageUpload img = new imageUpload();
       //     String extn = img.getExtensn(imageName);

            //System.out.println("bimla5");
            File fileNme = new File(imageName);
            File outputGrayImage = grayImage.imagePreprocessing(imageName+"."+"jpg", "jpg");
            out.println(outputGrayImage);
            String grayImageName = outputGrayImage.getName();
}

value of the variable is printed correctly inside jsp page. but when I try to acceess the variable value through servlet page it gives a null value. I have used hidden field in jsp page even. but it also gives the null value. I used sessions even. It also gives the null value. Do you have any idea?

0 Answers0