JAX-RS @FormParam example

In JAX-RS, you can use @FormParam annotation to bind HTML form parameters value to a Java method. The following example show you how to do it : 1. HTML Form See a simple HTML form with “post” method. <html> <body> <h1>JAX-RS @FormQuery Testing</h1> <form action="rest/user/add" method="post"> <p> Name : <input type="text" name="name" /> </p> <p> …

Read more

JAX-RS @QueryParam example

In JAX-RS, you can use @QueryParam annotation to inject URI query parameter into Java method. for example, /users/query?url=mkyong.com In above URI pattern, query parameter is “url=mkyong.com“, and you can get the url value with @QueryParam(“url”). 1. @QueryParam example See a full example of using @QueryParam in JAX-RS. import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.QueryParam; …

Read more

JAX-RS @MatrixParam example

Matrix parameters are a set of “name=value” in URI path, for example, /books/2011;author=mkyong In above URI, the matrix parameter is “author=mkyong“, separate by a semi colon “;“. 1. @MatrixParam example See a full example of using @MatrixParam in JAX-RS. import javax.ws.rs.GET; import javax.ws.rs.MatrixParam; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; @Path("/books") public class BookService { @GET …

Read more

JAX-RS @PathParam example

In JAX-RS, you can use @PathParem to inject the value of URI parameter that defined in @Path expression, into Java method. 1. @PathParam – Single Parameter A simple and normal way to use @PathParam. import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; @Path("/users") public class UserRestService { @GET @Path("{id}") public Response getUserById(@PathParam("id") String id) { …

Read more

4 ways to pass parameter from JSF page to backing bean

As i know,there are 4 ways to pass a parameter value from JSF page to backing bean : Method expression (JSF 2.0) f:param f:attribute f:setPropertyActionListener Let see example one by one : 1. Method expression Since JSF 2.0, you are allow to pass parameter value in the method expression like this #{bean.method(param)}. JSF page… <h:commandButton …

Read more

How to pass parameters in method expression – JSF 2.0

Since JSF 2.0, you are allow to pass parameter values in method expression like “#{bean.method(param)}“, but this feature will raising a “EL parsing error” on Tomcat server. For example, Managed Bean @ManagedBean(name="order") @SessionScoped public class OrderBean implements Serializable{ public String editAction(String id) { //… } } JSF page //… <h:commandLink value="Edit" action="#{order.editAction(123)}" /> //… If …

Read more

How to pass parameters to JSF 2.0 template file?

In JSF 2.0 web application, you can use “ui:param” facelets tag to pass parameters to an include file or a template file. 1. Parameter in “ui:include” Example to pass a “tagLine” parameter to an include file. <ui:insert name="header" > <ui:include src="/template/common/commonHeader.xhtml"> <ui:param name="tagLine" value="JSF a day, bug away" /> </ui:include> </ui:insert> In the commonHeader.xhtml file, …

Read more

How to display hibernate sql parameter values – Log4j

Problem Hibernate has basic logging feature to display the SQL generated statement with show_sql configuration property. Hibernate: INSERT INTO mkyong.stock_transaction (CHANGE, CLOSE, DATE, OPEN, STOCK_ID, VOLUME) VALUES (?, ?, ?, ?, ?, ?) However , it just isn’t enough for debugging, the Hibernate SQL parameter values are missing. Solution – Log4j Log4J is required to …

Read more

How to pass parameters to whole web application – ServletContext

Here’s a serlvet code example to demonstrate how to pass a parameter to whole web application by using ServletContext “init-param” in web.xml. In the deployment descriptor (web.xml) Put your parameter value in “init-param” and make sure outside the “servlet” element <servlet> <servlet-name>ServletName</servlet-name> <servlet-class>com.mkyong.ServletDemo</servlet-class> </servlet> <context-param> <param-name>email</param-name> <param-value>[email protected]</param-value> </context-param> Servlet code public void doGet(HttpServletRequest request, HttpServletResponse …

Read more

How to pass parameters to a servlet – ServletConfig

Here’s a serlvet code example to demonstrate how to pass a parameter to a servlet by using ServletConfig “init-param” in web.xml In the deployment descriptor (web.xml) Put your parameter value in “init-param” and make sure inside the “servlet” element <servlet> <servlet-name>ServletName</servlet-name> <servlet-class>com.mkyong.ServletDemo</servlet-class> <init-param> <param-name>email</param-name> <param-value>[email protected]</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>ServletName</servlet-name> <url-pattern>/Demo</url-pattern> </servlet-mapping> Servlet code public void …

Read more

How to display hibernate sql parameter values – P6Spy

Question There are many developers asking about Hibernate SQL parameter value question. How to display the Hibernate SQL parameter values that passed to database? Hibernate just display all parameter values as question mark (?). With show_sql property, Hibernate will shows all generated SQL statements, but not the SQL parameter values. For example Hibernate: insert into …

Read more