Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!

Sijesh Alayaril

Ranch Hand
+ Follow
since Jan 13, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sijesh Alayaril

Hello,  How do I call the 'onblur' event in Spring Controller.


Regards,




2 years ago
Dear all,

   I'm new to struts2 and while creating a dynamic menu I'm getting below exception, and the exception says "freemarker.template.TemplateException: Error reading included file template/simple/dynamic-attributes.ftl".

Please find the attached image for jar file used in application.

Error reading included file template/simple/dynamic-attributes.ftl
The problematic instruction:
----------
==> include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 30, column 1 in template/jquery/menu.ftl]
----------

Java backtrace for programmers:
----------


Is this issue is due to any jar compatibility? also I'm using following jar files,
      1.struts2-core-2.0.11.2.jar
      2.struts2-jquery-plugin-3.5.0.jar
      3.freemarker-2.3.8.jar

Here is my JSP File

menu.jsp
-----------
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
<html>
<head>
<title>Struts 2 - Login Application | ViralPatel.net</title>
</head>
<body>
<h2>Struts 2 - Login Application sdfsdf</h2>
<sj:menu id="menuWithItems" cssStyle="width:50%">
</sj:menu>
</body>
</html>

while using <sj:menu> tag in jsp page I'm getting above error.

Any help would be highly appreciated.



Kind Regards,
Sijesh



Deal All, Below issue killing my time, I'm working on spring MVC application and getting below exception while running the application.

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'person' available as request attribute.

Strange thing over here is I have added commandName or modelAttribute in jsp file also in controller as well.

Please see the below individual page details,

Person.jsp
------------

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ page session="false" %>
<html>
<head>
<title>Person Page</title>
<style type="text/css">
.tg  {border-collapse:collapse;border-spacing:0;border-color:#ccc;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ccc;color:#333;background-color:#fff;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ccc;color:#333;background-color:#f0f0f0;}
.tg .tg-4eph{background-color:#f9f9f9}
</style>
</head>
<body>
<h1>
Add a Person
</h1>

<c:url var="addAction" value="/person/add" ></c:url>

<form:form  metod="POST" action="${addAction}" modelAttribute="person">
<table>
<c:if test="${!empty person.name}">
<tr>
<td>
<form:label path="id">
<spring:message text="ID"/>
</form:label>
</td>
<td>
<form:input path="id" readonly="true" size="8"  disabled="true" />
<form:hidden path="id" />
</td>
</tr>
</c:if>
<tr>
<td>
<form:label path="name">
<spring:message text="Name"/>
</form:label>
</td>
<td>
<form:input path="name" />
</td>
</tr>
<tr>
<td>
<form:label path="country">
<spring:message text="Country"/>
</form:label>
</td>
<td>
<form:input path="country" />
</td>
</tr>
<tr>
<td colspan="2">
<c:if test="${!empty person.name}">
<input type="submit"
value="<spring:message text="Edit Person"/>" />
</c:if>
<c:if test="${empty person.name}">
<input type="submit"
value="<spring:message text="Add Person"/>" />
</c:if>
</td>
</tr>
</table>
</form:form>
<br>
<h3>Persons List</h3>
<c:if test="${!empty listPersons}">
<table class="tg">
<tr>
<th width="80">Person ID</th>
<th width="120">Person Name</th>
<th width="120">Person Country</th>
<th width="60">Edit</th>
<th width="60">Delete</th>
</tr>
<c:forEach items="${listPersons}" var="person">
<tr>
<td>${person.id}</td>
<td>${person.name}</td>
<td>${person.country}</td>
<td><a href="<c:url value='/edit/${person.id}' />" >Edit</a></td>
<td><a href="<c:url value='/remove/${person.id}' />" >Delete</a></td>
</tr>
</c:forEach>
</table>
</c:if>
</body>
</html>


PeronController.java
----------------------

@RequestMapping(value = "/persons", method = RequestMethod.GET)
public String listPersons(Model model) {
model.addAttribute("person", new Person());
model.addAttribute("listPersons", this.personService.listPersons());
return "person";
}

web.xml
--------

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

<!-- Default page to serve -->
<welcome-file-list>
    <welcome-file>/WEB-INF/views/person.jsp</welcome-file>
</welcome-file-list>

</web-app>


Spring configuration File : servlet-context.xml
---------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">

<context:component-scan base-package="com.journaldev.spring" />

<tx:annotation-driven transaction-manager="transactionManager"/>

<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->


<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />

<!-- Handles HTTP GET requests for /resources/** by efficiently serving
up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />

<!-- Resolves views selected for rendering by @Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>

<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<beans:property name="driverClassName" value="com.mysql.jdbc.Driver" />
<beans:property name="url"
value="jdbc:mysql://localhost:3306/TestDB" />
<beans:property name="username" value="pankaj" />
<beans:property name="password" value="pankaj123" />
</beans:bean>

<!-- Hibernate 4 SessionFactory Bean definition -->
<beans:bean id="hibernate4AnnotatedSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="annotatedClasses">
<beans:list>
<beans:value>com.journaldev.spring.model.Person</beans:value>
</beans:list>
</beans:property>
<beans:property name="hibernateProperties">
<beans:props>
<beans:prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect
</beans:prop>
<beans:prop key="hibernate.show_sql">true</beans:prop>
</beans:props>
</beans:property>
</beans:bean>

<beans:bean id="personDAO" class="com.journaldev.spring.dao.PersonDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</beans:bean>
<beans:bean id="personService" class="com.journaldev.spring.service.PersonServiceImpl">
<beans:property name="personDAO" ref="personDAO"></beans:property>
</beans:bean>

<beans:bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</beans:bean>

</beans:beans>


Kind Regards,
Sijesh
3 years ago
This issue has been resolved. Please find the below resolution.

<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

<!-- Default page to serve -->
<welcome-file-list>
    <welcome-file>/WEB-INF/views/person.jsp</welcome-file>
</welcome-file-list>

Thank you.

Kind Regards,
Sijesh
3 years ago
Dear All,
 I'm getting below error while running my application,

org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/SpringMVCHibernate/] in DispatcherServlet with name 'appServlet'

Web.xml
----------
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

<!-- Default page to serve -->
<welcome-file-list>
    <welcome-file>/views/person.jsp</welcome-file>
</welcome-file-list>

</web-app>

Can anyone please help me to figure out the issue.
3 years ago
In our application we have to give Stamp for each customers during medical insurance checkup. So each stamp cost certain amount or price.This money transaction achieved by using Knet and we have to integrate it with our application.

Hope I'm not confusing you :-)
3 years ago
KNET is a device and it is used in Payment Gateway.Hope you're clear now.
3 years ago
Dear All, I was looking into Knet integration in java. Could anyone help me on this please?



Kind Regards,
Sijesh


3 years ago
yes , I have worked with JSP. But quite new to HTML.
3 years ago
Hello, how to populate dynamic table content in HTML. Anyone please help me.



Regards,
Sijesh
3 years ago

     Michael, Already log4j.properties files are in resources folder. But it's not logging anything still.

Please see the below details,

log4j.properties
------------------
log4j.rootLogger=INFO, fileOut, stdOut, error
log4j.appender.fileOut = org.apache.log4j.RollingFileAppender
log4j.appender.fileOut.File = F://Virologylogs.log
log4j.appender.fileOut.MaxFileSize=10MB
log4j.appender.fileOut.MaxBackupIndex=10
log4j.appender.fileOut.layout=org.apache.log4j.PatternLayout
log4j.appender.fileOut.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

# Direct log messages to stdOut
log4j.appender.stdOut=org.apache.log4j.ConsoleAppender
log4j.appender.stdOut.Target=System.out
log4j.appender.stdOut.layout=org.apache.log4j.PatternLayout
log4j.appender.stdOut.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n


Pom.xml
----------

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>VIROLOGY-PRISM</groupId>
 <artifactId>VIROLOGY-PRISM</artifactId>
 <packaging>war</packaging>
 <version>0.0.1-SNAPSHOT</version>

<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>;
<layout>default</layout>
</repository>
</repositories>

<dependencies>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- Faces Implementation -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.4</version>
</dependency>

<!-- Faces Library -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>

<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.4</version>
</dependency>
<!-- Primefaces Version 5 -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.0</version>
</dependency>
<!-- JSP Library -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- JSTL Library -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>

</project>


FileUploadManagedBean.java
---------------------------------

package com.virology.lab.prism.bean;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.log4j.Logger;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.primefaces.model.UploadedFile;

@ManagedBean
@SessionScoped
public class FileUploadManagedBean {

final static Logger log = Logger.getLogger(FileUploadManagedBean.class);

UploadedFile file;

public UploadedFile getFile() {
return file;
}

public void setFile(UploadedFile file) {
this.file = file;
}


public void dummyAction(){

System.out.println("Uploaded File Name Is :: "+file.getFileName()+" :: Uploaded File Size :: "+file.getSize());


if(log.isInfoEnabled()){
log.info("This is info : ");
}

log.warn("This is warn : ");
log.error("This is error : ");
log.fatal("This is fatal : ");


      int nPos=-1;
      int nPos1=-1;
      int nPos2=-1;
      String  strDate=null;
      String strSampleID=null;
      String strRack=null;
      String strPos=null;
      String strExamType=null;
      int nExamType=-1;
      String strVal=null;
      String strOps=null;
      String strExamTime=null;
      int x=-1;
     
      log.info("Inside method");
      log.debug("In Debug mode level");
      log.trace("ddddddddddddd");
       
       DataInputStream dis = null;
       BufferedReader br = null;
       try {
       
         /* Here BufferedInputStream is added for fast reading.*/
        if(this.file!=null){
            dis = new DataInputStream(this.file.getInputstream());
            br = new BufferedReader(new InputStreamReader(dis));
        }
       
         String strLine;
         strLine= (br!=null)?br.readLine():null;          
         
         if(strLine != null){
             nPos=strLine.indexOf("|P|",0);
             /*System.out.println("Values of nPos |P| is"  );*/
         }
         
       if(nPos > -1) {
            strDate = strLine.substring(nPos+3,nPos+3+14);
            strDate=strDate.substring(4,6)+"/"+strDate.substring(6,8)+"/"+strDate.substring(0,4);                      
            /*System.out.println("Values of strDate is" +strDate);*/
       }

       while ((strLine = br.readLine()) != null)   {
           x=-1;
           if(strExamTime==null){
              if(strLine != null){
                  nPos=strLine.indexOf("|2|");
                  /*System.out.println("Values of nPos |2| is" +strDate);*/
              }
              if(nPos > -1){
                  strExamTime=strLine.substring(nPos+3,nPos+3+14);
              }
           }
            nPos=strLine.indexOf("O|1|",0);
           /* System.out.println("Values of nPos 0|1| is" +strDate);*/
            if (nPos>-1){
                  nPos = nPos+4;
                  nPos2 = strLine.indexOf("|",nPos);
                      if (nPos2>-1) {
                         strSampleID =strLine.substring(nPos,nPos2);
                              x=0;              
                              nPos1=strSampleID.indexOf("CALIBRATOR",0)+strSampleID.indexOf("Pos",0);
                              if (nPos1>-1) {
                                      x=1;
                              }else{
                                      nPos1=strSampleID.indexOf("POS",0);
                                      if( nPos1>-1 ){
                                              x=1;
                                      }
                              }
                      }
             }
             
             if (x==0){
             try{
            strRack= strLine.substring(nPos2+3,nPos2+5);
              strPos= strLine.substring(nPos2+6,nPos2+7);
                    nPos = strLine.indexOf("||",nPos2+6);
                    strExamType = strLine.substring(nPos+2,nPos+3);
             
             } catch(StringIndexOutOfBoundsException strexp){
             strexp.printStackTrace();
             }
            try{
              nExamType = Integer.parseInt(strExamType);
            }catch(Exception exp){
                exp.printStackTrace();
            }
             
            if (nExamType == 8 || nExamType == 1 ){
                      strExamType = "HIV";
                     
                      System.out.println("Sample ID " + strSampleID + " has the  Exam Type of " +strExamType +" in Rack  " +strRack +" & Position " +strPos);
                      /*System.out.println("SampleID " +strSampleID "has the  Exam Type of " +strExamType );*/
                     
            }else if( nExamType == 4 ){
                      strExamType = "HCV";
                      /*System.out.println("OutPut of the strExamType is " +strExamType);*/
                      /*System.out.println("Sample ID " + strSampleID + " has the  Exam Type of " +strExamType);*/
                      System.out.println("Sample ID " + strSampleID + " has the  Exam Type of " +strExamType +" in Rack  " +strRack +" & Position " +strPos);
            }else if (nExamType == 2) {
                      strExamType = "HBV";
                      /*System.out.println("OutPut of the strExamType is " +strExamType);*/
                      /*System.out.println("Sample ID " + strSampleID + " has the  Exam Type of " +strExamType);*/
                      System.out.println("Sample ID " + strSampleID + " has the  Exam Type of " +strExamType +" in Rack  " +strRack +" & Position " +strPos);
            }                                              
             strLine="";
                                             
                while ((strLine = br.readLine()) != null)   {                                            
                     
                        int t = strLine.indexOf("R|1|",0);
                      if(t > 0) {
                          StringBuffer sb = new StringBuffer(strLine);
                          strLine =sb.reverse().toString();
                          nPos = strLine.indexOf("|",0);
                          strVal = strLine.substring(nPos+16,nPos+20);
                          strOps = strLine.substring(nPos+1,nPos+2);
                          break;
                      }
                  }
            }
          }
//        accessGroupService.saveAccessGroup(accessGroup);
         br.close();
         dis.close();
       } catch (FileNotFoundException e) {
         e.printStackTrace();
       } catch (IOException e) {
         e.printStackTrace();
     }    
}
}


web.xml
---------
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5" metadata-complete="true">
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>

<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>auto</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

<welcome-file-list>
   <welcome-file>fileUpload.xhtml</welcome-file>
</welcome-file-list>

</web-app>



3 years ago
Michael, already my log4j.properties are in resources folder and no luck this time as well. This issue killing  me!!.

Here I'm adding my changes,

log4j.properties
-----------------
log4j.rootLogger=INFO, fileOut, stdOut, error
log4j.appender.fileOut = org.apache.log4j.RollingFileAppender
log4j.appender.fileOut.File = F://Virologylogs.log
log4j.appender.fileOut.MaxFileSize=10MB
log4j.appender.fileOut.MaxBackupIndex=10
log4j.appender.fileOut.layout=org.apache.log4j.PatternLayout
log4j.appender.fileOut.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

# Direct log messages to stdout
log4j.appender.stdOut=org.apache.log4j.ConsoleAppender
log4j.appender.stdOut.Target=System.out
log4j.appender.stdOut.layout=org.apache.log4j.PatternLayout
log4j.appender.stdOut.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n


Pom.xml
----------

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>VIROLOGY-PRISM</groupId>
 <artifactId>VIROLOGY-PRISM</artifactId>
 <packaging>war</packaging>
 <version>0.0.1-SNAPSHOT</version>

<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>;
<layout>default</layout>
</repository>
</repositories>

<dependencies>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- Faces Implementation -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.4</version>
</dependency>

<!-- Faces Library -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>

<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.4</version>
</dependency>
<!-- Primefaces Version 5 -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.0</version>
</dependency>
<!-- JSP Library -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- JSTL Library -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>

</project>

ManagedBean
----------------

package com.virology.lab.prism.bean;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.log4j.Logger;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.primefaces.model.UploadedFile;

@ManagedBean
@SessionScoped
public class FileUploadManagedBean {

final static Logger log = Logger.getLogger(FileUploadManagedBean.class);

UploadedFile file;

public UploadedFile getFile() {
return file;
}

public void setFile(UploadedFile file) {
this.file = file;
}


public void dummyAction(){

System.out.println("Uploaded File Name Is :: "+file.getFileName()+" :: Uploaded File Size :: "+file.getSize());


if(log.isInfoEnabled()){
log.info("This is info : ");
}

log.warn("This is warn : ");
log.error("This is error : ");
log.fatal("This is fatal : ");


      int nPos=-1;
      int nPos1=-1;
      int nPos2=-1;
      String  strDate=null;
      String strSampleID=null;
      String strRack=null;
      String strPos=null;
      String strExamType=null;
      int nExamType=-1;
      String strVal=null;
      String strOps=null;
      String strExamTime=null;
      int x=-1;
     
      log.info("Inside method");
      log.debug("In Debug mode level");
      log.trace("ddddddddddddd");
       
       DataInputStream dis = null;
       BufferedReader br = null;
       try {
       
         /* Here BufferedInputStream is added for fast reading.*/
        if(this.file!=null){
            dis = new DataInputStream(this.file.getInputstream());
            br = new BufferedReader(new InputStreamReader(dis));
        }
       
         String strLine;
         strLine= (br!=null)?br.readLine():null;          
         
         if(strLine != null){
             nPos=strLine.indexOf("|P|",0);
             /*System.out.println("Values of nPos |P| is"  );*/
         }
         
       if(nPos > -1) {
            strDate = strLine.substring(nPos+3,nPos+3+14);
            strDate=strDate.substring(4,6)+"/"+strDate.substring(6,8)+"/"+strDate.substring(0,4);                      
            /*System.out.println("Values of strDate is" +strDate);*/
       }

       while ((strLine = br.readLine()) != null)   {
           x=-1;
           if(strExamTime==null){
              if(strLine != null){
                  nPos=strLine.indexOf("|2|");
                  /*System.out.println("Values of nPos |2| is" +strDate);*/
              }
              if(nPos > -1){
                  strExamTime=strLine.substring(nPos+3,nPos+3+14);
              }
           }
            nPos=strLine.indexOf("O|1|",0);
           /* System.out.println("Values of nPos 0|1| is" +strDate);*/
            if (nPos>-1){
                  nPos = nPos+4;
                  nPos2 = strLine.indexOf("|",nPos);
                      if (nPos2>-1) {
                         strSampleID =strLine.substring(nPos,nPos2);
                              x=0;              
                              nPos1=strSampleID.indexOf("CALIBRATOR",0)+strSampleID.indexOf("Pos",0);
                              if (nPos1>-1) {
                                      x=1;
                              }else{
                                      nPos1=strSampleID.indexOf("POS",0);
                                      if( nPos1>-1 ){
                                              x=1;
                                      }
                              }
                      }
             }
             
             if (x==0){
             try{
            strRack= strLine.substring(nPos2+3,nPos2+5);
              strPos= strLine.substring(nPos2+6,nPos2+7);
                    nPos = strLine.indexOf("||",nPos2+6);
                    strExamType = strLine.substring(nPos+2,nPos+3);
             
             } catch(StringIndexOutOfBoundsException strexp){
             strexp.printStackTrace();
             }
            try{
              nExamType = Integer.parseInt(strExamType);
            }catch(Exception exp){
                exp.printStackTrace();
            }
             
            if (nExamType == 8 || nExamType == 1 ){
                      strExamType = "HIV";
                     
                      System.out.println("Sample ID " + strSampleID + " has the  Exam Type of " +strExamType +" in Rack  " +strRack +" & Position " +strPos);
                      /*System.out.println("SampleID " +strSampleID "has the  Exam Type of " +strExamType );*/
                     
            }else if( nExamType == 4 ){
                      strExamType = "HCV";
                      /*System.out.println("OutPut of the strExamType is " +strExamType);*/
                      /*System.out.println("Sample ID " + strSampleID + " has the  Exam Type of " +strExamType);*/
                      System.out.println("Sample ID " + strSampleID + " has the  Exam Type of " +strExamType +" in Rack  " +strRack +" & Position " +strPos);
            }else if (nExamType == 2) {
                      strExamType = "HBV";
                      /*System.out.println("OutPut of the strExamType is " +strExamType);*/
                      /*System.out.println("Sample ID " + strSampleID + " has the  Exam Type of " +strExamType);*/
                      System.out.println("Sample ID " + strSampleID + " has the  Exam Type of " +strExamType +" in Rack  " +strRack +" & Position " +strPos);
            }                                              
             strLine="";
                                             
                while ((strLine = br.readLine()) != null)   {                                            
                     
                        int t = strLine.indexOf("R|1|",0);
                      if(t > 0) {
                          StringBuffer sb = new StringBuffer(strLine);
                          strLine =sb.reverse().toString();
                          nPos = strLine.indexOf("|",0);
                          strVal = strLine.substring(nPos+16,nPos+20);
                          strOps = strLine.substring(nPos+1,nPos+2);
                          break;
                      }
                  }
            }
          }
//        accessGroupService.saveAccessGroup(accessGroup);
         br.close();
         dis.close();
       } catch (FileNotFoundException e) {
         e.printStackTrace();
       } catch (IOException e) {
         e.printStackTrace();
     }    
}
}

I'm not understanding what blocking to capture the log here?

3 years ago