How to send URL Parameter to Droplet to fetch data, in ATG?

URL is
http://<project>/blog/single.jsp?postid=20
Here postid is URL Parameter. We've to retrieve the post which id is 20.

Method #1:

In JSP
<dsp:setvalue bean="/its/blog/DisplayBlogDroplet.postId" value="${param.postid}"/>

In DropletClass (JAVA)

private Integer postId;

public Integer getPostId() {
return postId;
}

public void setPostId(Integer postId) {
this.postId = postId;
}

public void service(DynamoHttpServletRequest req,
DynamoHttpServletResponse res) throws ServletException, IOException{
RepositoryView singlepostView = getBlogRepository().getView("post");
RqlStatement singlepostStatement = RqlStatement.parseRqlStatement("post_id = ?0");
Object singlePostParams[] =new Object[1];
singlePostParams[0]=new Integer(getPostId());

Method: #2

In JSP

<dsp:droplet name="/its/blog/DisplayBlogDroplet">
<dsp:param name="postIdParam" value="${param.postid}"/>

In DropletClass (JAVA)

public void service(DynamoHttpServletRequest req,
DynamoHttpServletResponse res) throws ServletException, IOException{

String postIdParam = req.getParameter ("postIdParam");

RepositoryView singlepostView = getBlogRepository().getView("post");
RqlStatement singlepostStatement = RqlStatement.parseRqlStatement("post_id = ?0");
Object singlePostParams[] =new Object[1];
    singlePostParams[0]=new Integer(postIdParam);

Popular posts from this blog

[Solved] Hive installation error: java.net.URISyntaxException: Relative path in absolute URI

Install Android SDK in centOs

Installing arules package (Association Rules) in R