My button in a HTML page is:
<a id="showTrail" href="/resources/showTrail?roy=show" target="iframe_a">
<button>Show Trail</button>
</a>
My Java web service is:
package webServices;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Produces;
import javax.ws.rs.Consumes;
/**
* REST Web Service
*
* @author mkuchtiak
*/
@Stateless
@Path("/showTrail")
public class ShowTrail{
@EJB
private NameStorageBean nameStorage;
@GET
@Produces("text/html")
public String getXml() {
//String abc = request.getParameter("roy");
return "<html><body><h1>Hello "+nameStorage.getName()+"!</h1></body></html>";
}
@PUT
@Consumes("text/plain")
public void putXml(String content) {
nameStorage.setName(content);
}
}
How I can get a request parameter from the HTML?
Will the following line work?
String abc = request.getParameter("roy");
I want to send an HttpRequest
as parameter to send more parameters then "roy"