Passing parameters from client to server

Hi,

I want to pass a http parameter to the server side. Based on this parameter, I would like to customize my SQL query. How am i achieve this please ?

Thanks in advance,
Dushan

Please check this article viewtopic.php?f=14&t=9835&p=28172&hilit=post+method#p28172

Hi Olga,

Thank you for your response. The article shows how to pass the parameter from the client side and access the request variable from PHP POST[“paramName”] method.

I’m using Java back end and how do I access the HttpServletRequest object in-order to retrieve the passed parameter. The “doPost()” method is called in the ConnectorServlet class and the “request” object is not visible to the sub class (BasicConnector as per the example).

Thanks in advance,
Dushan

Hi,

I did the following work-around for the problem I faced using “ConnectorJava” package. Since the HttpServletRequest and HttpServletResponse objects are instantiating in the ConnectorServlet class and the instantiated objects are assigned to req, res protected variables in the BaseConnector class, I have written a custom class extending BaseConnector class in-order to access the req and res variables which are having protected access (Only immediate sub classes can access these).

import com.dhtmlx.connector.*;
import java.sql.Connection;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Dushan.Karawita
 */
public class MyBaseConnector extends BaseConnector {

    public static HttpServletRequest request;
    public static HttpServletResponse response;

    public MyBaseConnector(Connection db){
        super(db,DBType.Custom);
        
        request = BaseConnector.global_http_request;
        response = BaseConnector.global_http_response;
    }
}

Now I can access the request and response objects from my servlet class and retrieve any request parameters as follows,

MyBaseConnector myCon = new MyBaseConnector(conn);
String param = myCon.request.getParameter("paramName");