• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help for f nice question  RSS feed

Gaurav Chugh
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
i would like to discuss a question here , it as follows
Consider the following code for doStartTag() method of a tag handler.
public int doStartTag()
int retval = Tag.EVAL_BODY_INCLUDE;
Statement stmt = getConnection().createStatement();
ResultSet rs = stmt.executeQuery("select * from USERS");
if(rs == null | | !rs.next() ) retval = Tag.SKIP_BODY;
else doSomethingWithRS();
catch(Exception e)
retval = XXXXX; // 1
return retval;

In case of an exception you do not want the doEndTag() of this tag handler to be called. What value should be used at // 1 to satisfy this requirement?
the following options can be
1>Either it should return Tag.SKIP_BODY
2>Still we go the exception We can avoid doEndTag() to implement method at //1
3>None of These .
cud anybody explain which option is correct
Thanks in advance

with warm regards
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!