Skip to main content

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

#ThankYouCitrisys

MAY 5, 2015 an unforgettable day in my life. Why this award is so special to me? Because, after 8 years (After completion of Engineering), I landed on a good place where they identified me and involved me in the good projects with suitable PMOs. With all their support in Citrisys, I did small things with my involvement. For that, Citrisys, awarded me this "Award of Excellence". This award not shows me the best performance, but, it shows me to work more and more. Thank you Mr.ARA (CEO, Citrisys Solutions) for this award. #ThankYouCitrisys

Citrisys Poster Competition work 02