0

from a jsf page I am calling a servlet that consumes a webservice, when I click send, there is no action, it does not call the servelt.

this is Servlet Parqueo

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
   Map<String,String> requestParams = ec.getRequestParameterMap();
   String Nombre = requestParams.get("nombre");
   String Tipo = requestParams.get("tipo");
   String Placa = requestParams.get("tipo");
   String Fecha= requestParams.get("fecha");
   String Hora_in = requestParams.get("horain");
   String Hora_out= requestParams.get("horaout");
   if(Hora_in !=null && !Hora_in.isEmpty() && Hora_out !=null && !Hora_out.isEmpty()){
   jaxws.Parking_Service service;
   jaxws.Parking port;
   try{
   service= new jaxws.Parking_Service();
   port=service.getParkingPort();
   String parqueo = port.reserva(Hora_in, Hora_out);
   request.setAttribute("result",parqueo);
   response.getWriter().print( Nombre + "</p>");
   response.getWriter().print( Tipo + "</p>");
   response.getWriter().print( Placa + "</p>");
   response.getWriter().print( Fecha + "</p>");
   request.getRequestDispatcher("reserva.xhtml").forward(request, response);
   }

I receive the data of the index, I save them and I consume the webservice, then I send the data and the result to the page resultado.xhtml

this is index.xhtml from this page I call serlvet

  <h:body>
    <f:view>
     <h:form>
            <h:outputText value="Reserva de Parqueadero "  />
            <br/>                        
        <h:panelGrid columns="2">
    <p:outputLabel value="Nombre:" for="nombre" />
    <p:inputText id="nombre" title="Nombre" required="true" requiredMessage="The Id field is required."/>
    <p:outputLabel value="Tipo:" for="tipo" />
    <p:inputText id="tipo" title="Tipo" required="true" requiredMessage="The Id field is required."/>      
    <p:outputLabel value="Placa:" for="placa" />
    <p:inputText id="placa" title="Placa" required="true" requiredMessage="The Id field is required."/>       
    <p:outputLabel value="Hora Ingreso:" for="horain" />
    <p:inputText id="horain" title="Hora Ingreso" required="true" requiredMessage="The Id field is required."/>       
    <p:outputLabel value="Hora Salida:" for="horaout" />
    <p:inputText id="horaout" title="Hora Salida" required="true" requiredMessage="The Id field is required."/>        
    <p:outputLabel value="Fecha:" for="fecha" />
    <p:calendar id="fecha" value="#{calendar.date1}" showOn="button" navigator="true"></p:calendar>   
         </h:panelGrid>
         <br/>
        <h:commandButton value="Enviar" action="/parqueo.do"/> 
    </h:form>   
    </f:view>      
 </h:body>

this is result.xhtml

<h:body>
    <f:view>
    <h:outputText value="Nombre" />
    <h:outputText value="#{session.getAttribute(name)}"/>
    <h:outputText value="Tipo" />
    <h:outputText value="#{session.getAttribute(tipo)}"/>
    <h:outputText value="Placa" />
    <h:outputText value="#{session.getAttribute(placa)}"/>
    <h:outputText value="Fecha" />
    <h:outputText value="#{session.getAttribute(fecha)}"/>
    <f:convertDateTime pattern="MM/dd/yyyy" />
    <h:outputText value="Resultado" />
    <h:outputText value="${result}"/>
  </f:view>
 </h:body>

on this page it should show the data entered and the value returned by the webservice that is parqueo

this is web.xml

 <servlet>
    <servlet-name>Parqueo</servlet-name>
    <servlet-class>controlador.Parqueo</servlet-class>
</servlet>
 <servlet-mapping>
    <servlet-name>Parqueo</servlet-name>
    <url-pattern>/parqueo.do</url-pattern>
</servlet-mapping>
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • You indeed have a very uncommon setup. make services call these from either a managed bean, servlet or rest frontend. – Kukeltje May 29 '18 at 05:39
  • And learn the basics of jsf via a modern tutorial (**NOT** tutorialspoint or the likes) but start on http://jsf.zeef.com – Kukeltje May 29 '18 at 06:59
  • https://stackoverflow.com/questions/30639785/jsf-controller-service-and-dao – Kukeltje May 29 '18 at 07:40

1 Answers1

0

Why are you using a servlet? If you are using JSF then use a ManagedBean for link it whit some UI Component (the Faces Servlet will map the request/post for you).