Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate Custom Tag that talks to the database
    primarykey
    data
    text
    <p>I want to create a custom tag that talks to the database and retreives records from a table and then displays on a jsp page.</p> <p>I am using spring. and Eclipselink as JPA provider. I wrote a custom class.</p> <pre><code>package com.persistent.testjpa.taghandlers; import java.io.IOException; import java.util.Date; import java.util.List; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.SimpleTagSupport; import org.springframework.beans.factory.annotation.Autowired; import com.persistent.testjpa.dao.MyUserDao; import com.persistent.testjpa.domain.MyAuthorities; public class MyListTagHandler extends SimpleTagSupport { private String tableName; private MyUserDao dao; public String getTableName() { return tableName; } public void setTableName(String tableName) { this.tableName = tableName; } public void doTag() throws JspException, IOException { System.out.println("Indise Do Tag Method"); JspWriter out = getJspContext().getOut(); if (tableName != null) { System.out.println("Table Name : "+getTableName()); out.println("&lt;html&gt;&lt;body&gt;"); out.println("Today's Date is "+ new Date()); out.println("&lt;/body&gt;&lt;/html&gt;"); } else { out.println("&lt;html&gt;&lt;body&gt;"); out.println("Please Enter Table Name"); out.println("&lt;/body&gt;&lt;/html&gt;"); } } @Autowired public void setDao(MyUserDao dao) { this.dao = dao; } public List&lt;MyAuthorities&gt; getList(){ return dao.list(); } } </code></pre> <p>When I try to access the Dao Object The code throws a NullPointer Exception.</p> <p>Can someone tell me what's wrong?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload