I am trying to develop a simple application using angularjs and spring mvc restful web service. At first, I have to load the index file where it makes an http call http://localhost:8088/angular/demo to get some json data from the server. But I get a 406 not acceptable error for this.
The first method in the controller, I have written to load the main page and the second method should respond with user information as JSON.
Is it wrong to have a method returning modelAndView and another returning data in the same controller?
If I use only methods serving JSON data in the controller, then how should I load the first page?
I have included all the required libraries in the lib folder.
In index.jsp i have:
$scope.displayUsers=function(){
$http({
method : 'GET',
url : urlBase+'/demo'
}).success(function(response) {
var response = JSON.parse(response)
alert(response);
console.log(response);
});
}
//---call the display users method
$scope.displayUsers();
The controller is :
#RestController
public class Controller {
#RequestMapping("/")
public ModelAndView helloWorld()
{
ModelAndView model=new ModelAndView("index");
model.addObject("msg", "Hello World");
return model;
}
#RequestMapping(value="/demo", method = RequestMethod.GET)
public #ResponseBody List<Data> getAllTasks() {
List<Data> tasks=new ArrayList<Data>() ;
Data data=new Data();
data.setName("Abc");
data.setEmail("abc#xyz.com");
tasks.add(data);
return tasks;
}
}
The resource representation class is:
public class Data {
String name;
String email;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
web.xml:
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Angular Rest Spring</display-name>
<servlet>
<servlet-name>angular</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>angular</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
angular-servlet.jsp :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<context:component-scan base-package="com.gitanjal.angular"/>
<mvc:annotation-driven />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
Related
When I use log4j and TestNG #DataProvider I was able to generate logs for the below code, but when I use #DataProvider the logs are getting overwritten. I tried to use #BeforeTest but it's not working. Any idea on how can I generate for logs for all the my rows?
public class DemoTest extends baseFX {
public static Logger Log = LogManager.getLogger(baseFX.class.getName());
#Test(dataProvider="DataProvider", groups = { "baseFX" })
public void loginPageNav(String Test, String newMemEmail, String newMemPass ) throws Exception {
driver=driverSetup();
Log.info("Driver is initialized");
//Creating object for the Index to the class
IndexPage indexpage = new IndexPage(driver);
Log.info("Navigated to Index Page");
//invoke method
indexpage.clickLogin().click();
Log.info("Clicked on Login");
//Creating an object for the login page and invoke its elements
LoginPage loginpage = new LoginPage(driver);
loginpage.getPassword().sendKeys(password);
loginpage.loginBtn().click();
Log.info("Member successfully logged in");
//driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
driver.close();
}
#DataProvider
public Object[][] DataProvider() throws Exception{
Object[][] arrayObject = ReadExcelData.getExcelData("./src/test/java/Autopkg/TestData/Demo.xlsx", "Sheet1");
return arrayObject;
}
//#AfterTest
//public void tearDown(){
//}
}
I use log4j configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
<Property name="basePath">./logs</Property>
</Properties>
<Appenders>
<RollingFile name="File" fileName="${basePath}/prints.log" filePattern="${basePath}/prints-%d{yyyy-MM-dd}.log">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
<SizeBasedTriggeringPolicy size="1000" />
</RollingFile>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="File"/>
</Root>
</Loggers>
</Configuration>
I am using Solr + Spring Data Solr for Solr Indexing.
I am getting following error when I am trying save the solr document.
HTTP Status 500 - Request processing failed; nested exception is org.springframework.data.solr.UncategorizedSolrException: Expected mime type application/octet-stream but got text/html.
Here is my code:
Config:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:solr="http://www.springframework.org/schema/data/solr"
xsi:schemaLocation="http://www.springframework.org/schema/data/solr http://www.springframework.org/schema/data/solr/spring-solr.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<solr:repositories base-package="my.solr.repo"
multicore-support="true" />
<solr:solr-server id="solrServer" url="http://localhost:8983/solr" />
<bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate">
<constructor-arg index="0" ref="solrServer" />
</bean>
</beans>
#Repository
public class SolrMyRepository extends
SimpleSolrRepository<SolrmyModel, Serializable> {
#Autowired
public SolrMyRepository(final SolrTemplate solrTemplate) {
super(solrTemplate);
}
}
#SolrDocument(solrCoreName = "my")
public class SolrMyModel {
#Id
#Indexed
private Long id;
#Indexed
private String myTitle;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMyTitle() {
return myTitle;
}
public void setMyTitle(String myTitle) {
this.myTitle = myTitle;
}
}
#Service
public class SolrMyService {
#Autowired
private SolrMyRepository solrMyRepository;
public void test() {
final SolrMyModel model = new SolrMyModel();
model.setId((long) 1);
model.setTitle("My title");
System.out.println(model);
solrMyRepository.save(model);
}
}
I am not sure what else I am missing but constantly I am getting this error.
Solution:
I got over the above problem as I have not create a solr core by running following command.
./solr create -c my
As now its working, how can I created core programatically?
I got over the above problem as I have not create a solr core by running following command.
./solr create -c my
I've read many topics with the same problem like my but it didn't solved so I've decided write here.
The problem is that when I want to edit or delete record in my project, every function implemented in Java seems to run correctly, but there aren't any changes in database.
For example in my project I've got model called 'Oddzial' (in english it's department).
I can add new Oddzial (Department) to the database and I'll see the changes. But if I want to delete everything, there aren't any errors but also there aren't any changes in database. The record which should be deleted is still in database.
Here are my files:
Model:
#Entity
#Table(name="oddzial")
public class Oddzial implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue
private Integer oddzial_id;
#Size(min=3, max=25, message="test message.")
private String miasto;
#Size(min=5, max=50, message="test message.")
private String ulica;
public Integer getOddzial_id() {
return oddzial_id;
}
public void setOddzial_id(Integer oddzial_id) {
this.oddzial_id = oddzial_id;
}
public Integer getId() {
return oddzial_id;
}
public void setId(Integer id_oddzial) {
this.oddzial_id = id_oddzial;
}
public String getMiasto() {
return miasto;
}
public void setMiasto(String miasto) {
this.miasto = miasto;
}
public String getUlica() {
return ulica;
}
public void setUlica(String ulica) {
this.ulica = ulica;
}
#Override
public String toString() {
return "[" + oddzial_id + "] " + ulica + " " + miasto;
}
}
Here is Oddzial's DAO:
#Repository
public class OddzialDAOImpl implements OddzialDAO {
#Autowired
private SessionFactory sessionFactory;
private Session getCurrentSession() {
return sessionFactory.getCurrentSession();
}
public void addOddzial(Oddzial oddzial) {
getCurrentSession().save(oddzial);
}
public void updateOddzial(Oddzial oddzial) {
Oddzial oddzialToUpdate = getOddzial(oddzial.getId());
oddzialToUpdate.setMiasto(oddzial.getMiasto());
oddzialToUpdate.setUlica(oddzial.getUlica());
getCurrentSession().update(oddzialToUpdate);
}
public Oddzial getOddzial(int id) {
Oddzial oddzial = (Oddzial) getCurrentSession().get(Oddzial.class, id);
return oddzial;
}
public void deleteOddzial(int id) {
Oddzial oddzial = getOddzial(id);
if (oddzial != null)
getCurrentSession().delete(oddzial);
}
#SuppressWarnings("unchecked")
public List<Oddzial> getOddzialy() {
return getCurrentSession().createQuery("from Oddzial").list();
}
}
Here is OddzialService:
#Service
#Transactional
public class OddzialServiceImpl implements OddzialService {
#Autowired
private OddzialDAO oddzialDAO;
#Override
public void addOddzial(Oddzial oddzial) {
oddzialDAO.addOddzial(oddzial);
}
#Override
public void updateOddzial(Oddzial oddzial) {
oddzialDAO.updateOddzial(oddzial);
}
#Override
public Oddzial getOddzial(int id) {
return oddzialDAO.getOddzial(id);
}
#Override
public void deleteOddzial(int id) {
oddzialDAO.deleteOddzial(id);
}
#Override
public List<Oddzial> getOddzialy() {
return oddzialDAO.getOddzialy();
}
}
And here is Controller:
#Controller
#RequestMapping(value="/oddzial")
public class OddzialController {
#Autowired
private OddzialService oddzialService;
#RequestMapping(value="/add", method=RequestMethod.GET)
public ModelAndView addOddzialPage() {
ModelAndView modelAndView = new ModelAndView("add-oddzial-form");
modelAndView.addObject("oddzial", new Oddzial());
return modelAndView;
}
#RequestMapping(value="/add", method=RequestMethod.POST)
public String addingOddzial(#ModelAttribute #Valid Oddzial oddzial, BindingResult result) {
if(result.hasErrors()) {
return "add-oddzial-form";
}
oddzialService.addOddzial(oddzial);
String message = "Oddział został pomyślnie dodany do bazy.";
return "list-of-oddzials";
}
#RequestMapping(value="/list")
public ModelAndView listOfOddzials() {
ModelAndView modelAndView = new ModelAndView("list-of-oddzials");
List<Oddzial> oddzials = oddzialService.getOddzialy();
modelAndView.addObject("oddzials", oddzials);
return modelAndView;
}
#RequestMapping(value="/edit/{id}", method=RequestMethod.GET)
public ModelAndView editOddzialPage(#PathVariable Integer id) {
ModelAndView modelAndView = new ModelAndView("edit-oddzial-form");
Oddzial oddzial = oddzialService.getOddzial(id);
modelAndView.addObject("oddzial",oddzial);
return modelAndView;
}
#RequestMapping(value="/edit/{id}", method=RequestMethod.POST)
public ModelAndView edditingOddzial(#ModelAttribute Oddzial oddzial, #PathVariable Integer id) {
ModelAndView modelAndView = new ModelAndView("home");
oddzialService.updateOddzial(oddzial);
String message = "Dane zostały zmodyfikowane.";
modelAndView.addObject("message", message);
return modelAndView;
}
#RequestMapping(value="/delete/{id}", method=RequestMethod.GET)
public ModelAndView deleteOddzial(#PathVariable Integer id) {
ModelAndView modelAndView = new ModelAndView("home");
oddzialService.deleteOddzial(id);
String message = "Oddział został usunięty.";
modelAndView.addObject("message", message);
return modelAndView;
}
}
The content of my Spring configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:flow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
">
<!-- Root Context: defines shared resources visible to all other web components -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/tutorial" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="pl.carrental" />
<property name="hibernateProperties">
<props>
<prop key="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<bean id="passwordEncoder"
class="org.springframework.security.authentication.encoding.ShaPasswordEncoder">
<constructor-arg value="256" />
</bean>
<bean id="saltSource"
class="org.springframework.security.authentication.dao.ReflectionSaltSource">
<property name="userPropertyToUse" value="username" />
</bean>
<!-- <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="flowRegistry"></property> </bean> <bean
class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter"> <property
name="flowExecutor" ref="flowExecutor"></property> </bean> <flow:flow-executor
id="flowExecutor" flow-registry="flowRegistry" /> <flow:flow-registry id="flowRegistry"
base-path="/WEB-INF/flows"> <flow:flow-location-pattern value="/**/*-flow.xml"
/> </flow:flow-registry> -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
<bean
class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
<tx:annotation-driven transaction-manager="transactionManager" />
<context:component-scan
base-package="pl.carrental" />
The content of web.xml:
<?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" 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_3_0.xsd"
version="3.0">
<!-- 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
/WEB-INF/spring/spring-security.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>
<!-- 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>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>localizationFilter</filter-name>
<filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>localizationFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Thanks in advance for help
SOLVED. The line:
<tx:annotation-driven transaction-manager="transactionManager" />
must be in servlet-context.xml. Not in root-config.xml like in my case. Now transactions are committed and I can delete and update records.
I developed a web service with CXF and It work fine.
I have a service with two input parameters and both of them should be mandatory.
but when I call my service just the first parameter is mandatory.
please let me know what should I do?
my SEI
#WebService(
endpointInterface = "com.myCompany.product.webService",
targetNamespace = "http://product.myCompany.com",
portName = "product",
serviceName = "ProductService")
#DataBinding(org.apache.cxf.aegis.databinding.AegisDatabinding.class)
public interface ProductService {
#WebMethod(operationName = "authentication")
#WebResult(name = "authenticationResponseParam")
public AuthenticationResponseParam authentication(#WebParam(name = "user", header = true) String user,
#WebParam(name = "authenticationRequestParam") AuthenticationRequestParam authenticationRequestParam);
}
and my AuthenticationResponseParam class
#XmlAccessorType(XmlAccessType.FIELD
)
#XmlType(name = "authenticationRequestParam", propOrder = {
"account", "password"
})
public class AuthenticationRequestParam implements Serializable {
#XmlElement(name = "account", required = true)
private BigDecimal account;
#XmlElement(name = "password", required = true)
private String password;
public BigDecimal getAccount() {
return account;
}
public void setAccount(BigDecimal account) {
this.account = account;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
#Override
public String toString() {
return "AuthenticationRequestParam{" +
"account=" + account +
", password='" + password + '\'' +
'}';
}
}
and my CXF servlet xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
<!--Data binding-->
<bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding" scope="prototype"/>
<bean id="jaxws-and-aegis-service-factory"
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
scope="prototype">
<property name="dataBinding" ref="aegisBean"/>
</bean>
<jaxws:endpoint id="telBank" implementor="#myService" address="/telBank">
<jaxws:binding>
<soap:soapBinding mtomEnabled="false" version="1.2"/>
</jaxws:binding>
</jaxws:endpoint>
<bean id="myService" class="com.myCompany.product.webService.impl.ProductServiceImpl"/>
</beans>
thank you
Hey guys
I added a new service in my web service
public BigDecimal sample(#WebParam(name = "sam1") BigDecimal a1,#WebParam(name = "sam2") BigDecimal a2);
and none of both parameters are mandatory
what should I do?please help me
I found what my problem.
I use org.apache.cxf.aegis.databinding.AegisDatabinding az data binder and it just recognize primitive type az mandatory.when I commend that my input param become mandatory.
what kind of data binder should I use?
If you want to use AegisDatabinding class as data binder,set this property it bean definition.
<bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding" scope="prototype">
<property name="configuration">
<bean class="org.apache.cxf.aegis.type.TypeCreationOptions">
<property name="defaultMinOccurs" value="1"/>
<property name="defaultNillable" value="false"/>
</bean>
</property>
</bean>
I have looked around for a while looking for a complete guide for this. I've been working with JSF like 2 days now and am trying to make a page that will upload a pdf file to a server, putting its file path into a database along with other user-inputted text fields.
This is my form (so far)
<h:form enctype="multipart/form-data">
<h:outputText value="Name: " />
<h:inputText id="name" size="40" value="#{resumeBean.name}" required="true"/> <br/>
<h:outputText value="Position Sought: "/>
<h:inputText id="position" size="40" value="#{resumeBean.position}" required="true"/> <br/>
<h:outputText value="Date: " />
<h:inputText id="date" size="40" value="#{resumeBean.date}" required="true" /> <br/>
<h:outputText value="File to upload: " />
<t:inputFileUpload value="#{bean.resume}" /> <br/>
<h:commandButton value="submit" action="#{bean.submit}" />
<h:messages />
</h:form>
and this bean to handle the file
package com.example;
import java.io.IOException;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import org.apache.commons.io.FilenameUtils;
import org.apache.myfaces.custom.fileupload.UploadedFile;
#ManagedBean
#RequestScoped
public class Bean {
private String name, position, date;
private String fileName;
private UploadedFile resume;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public void setResume(UploadedFile resume) {
this.fileName = resume.getName();
this.resume = resume;
}
public UploadedFile getResume() {
return resume;
}
public String getFileName() {
return fileName;
}
public void submit() throws IOException {
String fileName = FilenameUtils.getName(resume.getName());
String contentType = resume.getContentType();
byte[] bytes = resume.getBytes();
// Now you can save bytes in DB (and also content type?)
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(String.format("File '%s' of type '%s' successfully uploaded!", fileName, contentType)));
}
}
web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app
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_3_0.xsd"
id="timesheet2" version="3.0">
<display-name></display-name>
<welcome-file-list>
<welcome-file>faces/login.xhtml</welcome-file>
</welcome-file-list>
<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>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
</web-app>
but from here I have no idea how to continue, help please?
thanks in advance
BalusC has made a blog post about File Uploading by building a custom tag component, pure JSF based for JSF 2.0 and 2.1. Since JSF 2.2, there's a JSF component for file uploading: <h:inputFile>.
Also, you can look another implementations like PrimeFaces FileUpload and RichFaces FileUpload.
Might I recommend the PrimeFaces FileUploader?