Appeal from the Circuit Court of Lake County. No. 98-CF-3375 Honorable Victoria A. Rossetti, Judge, Presiding.
 The opinion of the court was delivered by: Presiding Justice O'malley
 Defendant, Albert S. Winfrey, appeals the trial court's summary denial of his habeas corpus petition. He contends that, in dismissing his petition, the court improperly treated it as a post-conviction petition. We reverse and remand.
 Defendant filed a pro se petition for habeas corpus relief. See 735 ILCS 5/10--101 et seq. (West 2002). In his petition, he argued that the Department of Corrections (DOC) had revoked his good-conduct credit in violation of the Illinois Administrative Code (20 Ill. Adm. Code §504.10 et seq. (West 2002)) and that he had been denied his right to fairly grieve the decision. The State did not file an answer to the petition or a motion to dismiss it. The court denied the petition sua sponte. Defendant had no notice of and no opportunity to respond to the court's denial of his petition. He timely appealed.
 Defendant contends that the trial court erred in summarily denying his pleading as if it were a post-conviction petition filed pursuant to the Post-Conviction Hearing Act (the Act) (725 ILCS 5/122--1 et seq. (West 2002)). Whether the court complied with the applicable statutory procedure is a question of law and our review is de novo. See Woods v. Cole, 181 Ill. 2d 512, 516 (1998).
 We hold that the court erred in summarily denying defendant's habeas corpus petition. In People v. Gaines, 335 Ill. App. 3d 292 (2002), and People v. Shellstrom, 345 Ill. App. 3d 175 (2003), we addressed this same procedural issue in two related contexts. In Gaines, the defendant filed a petition seeking relief from judgment pursuant to section 2--1401 of the Code of Civil Procedure (the Code) (735 ILCS 5/2--1401 (West 2002)). The State urged the trial court to treat the petition like a post-conviction petition and make an initial determination before requiring the State to respond. The trial court followed the State's suggestion and dismissed the petition in a manner resembling a summary dismissal under the Act. The defendant appealed and we reversed. We held that the "particular statutory procedures applicable to petitions under the Act do not apply to section 2--1401 proceedings." Gaines, 335 Ill. App. 3d at 295. We reasoned that while the Act allows the trial court to independently consider and summarily dismiss a post-conviction petition, "section 2--1401 has no corresponding provision for independent examination by the trial court, nor is the trial court authorized to summarily dismiss a section 2--1401 petition." Gaines, 335 Ill. App. 3d at 296. We also noted that a section 2--1401 petition is similar to a complaint in a civil action, and hence the opponent must either move to dismiss it or file an answer. Gaines, 335 Ill. App. 3d at 296; see also People v. Pearson, 345 Ill. App. 3d 191, 194-95 (2003).
 In Shellstrom, the defendant filed a complaint pursuant to the mandamus statute (735 ILCS 5/14--101 et seq. (West 2002)). The trial court treated the complaint as a post-conviction petition pursuant to the Act and summarily dismissed it. The defendant had no notice of and no opportunity to respond to the trial court's dismissal of his complaint. He appealed and we reversed. We held that the mandamus statute did not authorize the trial court to summarily dismiss a mandamus complaint. Shellstrom, 345 Ill. App. 3d at 177. We also held that the summary dismissal of the complaint contravened section 2--612(a) of the Code (735 ILCS 5/2--612(a) (West 2002)); while the trial court could have struck the defendant's complaint and ordered other pleadings prepared, it could not dismiss the complaint on its own motion, unless the complaint failed to state a cognizable cause of action recognized in this state. Shellstrom, 345 Ill. App. 3d at 177; see also Mitchell v. Norman James Construction Co., Inc., 291 Ill. App. 3d 927, 938 (1997). Finally, we held that even if the complaint did fail to state a cognizable cause of action, the court erred because the defendant was given neither notice nor an opportunity to be heard on the issues upon which the trial court based its dismissal. Shellstrom, 345 Ill. App. 3d at 177-78; see also Pearson, 345 Ill. App. 3d at 193-95.
 The reasoning in Gaines and Shellstrom applies here as well. The habeas corpus statute, which is contained within the provisions of the Code, does not authorize the trial court to summarily deny a habeas corpus petition. Moreover, the trial court's summary denial contravened section 2--612(a) of the Code. See Shellstrom, 345 Ill. App. 3d at 177. Finally, defendant was given no notice of and no opportunity to respond to the trial court's denial of his petition. Accordingly, the trial court committed reversible error when it summarily denied defendant's petition.
 The State argues that we should follow Mason v. Snyder, 332 Ill. App. 3d 834 (2002). In Mason, the defendant filed a pro se mandamus complaint. The trial court dismissed it sua sponte. The Appellate Court, Fourth District, held that a trial court may evaluate and dismiss sua sponte a mandamus complaint. The court reasoned:
 "[T]rial courts may evaluate such petitions to determine their sufficiency, particularly when filed by DOC inmates. In so concluding, we take judicial notice of our own records, which show an ever-increasing number of appeals brought by inmates in such cases, as well as the fact that DOC currently houses over 46,000 inmates. The potential to overwhelm the courts and the civil justice system by the filing of groundless DOC inmate mandamus petitions is clear and real, and one first step to deal with this situation is to recognize the trial court's authority to evaluate such petitions for their sufficiency." Mason, 332 Ill. App. 3d at 840.
 The State contends that the same reasoning applies in the context of habeas corpus petitions.
 We rejected this reasoning in Shellstrom, and we do so again here. In Shellstrom, we held:
 "While [the difficulty of dealing with the volume of mandamus complaints filed by DOC inmates] is a real concern for trial courts, we should not attempt to remedy this concern by reading into the mandamus statute a summary dismissal procedure that is not there. The procedural framework of mandamus actions is not a policy issue for the courts to decide but, rather, a legislative decision to be made by the General Assembly. Accordingly, it is the province of the legislature, not the judiciary, to amend the statute to allow for summary dismissals.
 The Code, including the mandamus statute, provides a clear procedural framework that applies regardless of the merits of the allegations in the complaint. Accordingly, the fact that a mandamus complaint appears meritless does not excuse compliance with the procedural provisions of the Code. Additionally, the fact that a mandamus plaintiff is a DOC inmate in no way invests the ...