facebook

nullpointer for pageContext

  1. MyEclipse IDE
  2.  > 
  3. Comments
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #215966 Reply

    glurps
    Member

    i get a nullpointer for ‘pageContext’ in:

    package taglibs;
    import java.io.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    
    public class OldSchool extends TagSupport {
        private JspWriter out = pageContext.getOut();
        
        public int doStartTag() throws JspException {
            try {
                out.println("hello world");
            }
            catch (IOException e){
                throw new JspException(e);
            }
            return SKIP_BODY;
        }
    }

    i had no problem doing so in the old syntax but xml-style seams not to work.

    i am not sure if line 4 is correct in the .tdl:

    <?xml version="1.0" encoding="UTF-8"?>
    <taglib xmlns="http://java.sun.com/xml/ns/j2ee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
            version="2.0">
    
        <description>oldschool test</description>
        <tlib-version>1.0</tlib-version>
        <short-name>oldschooltest</short-name>
        
        <tag>
            <description>test oldschool tags</description>
            <name>helloworld</name>
            <tag-class>taglibs.OldSchool</tag-class>
            <body-content>empty</body-content>
        </tag>
    
    </taglib>

    for completness the jspx where the tag gets included:

    <?xml version="1.0" encoding="UTF-8"?>
    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:jsp="http://java.sun.com/JSP/Page"
          xmlns:oldschool="urn:jsptld:/WEB-INF/tlds/oldschool.tld"
          xml:lang="en">
    
    <jsp:directive.include file="deploytype.jspx" />
    
    <head></head>
    
        <body>
              
            <oldschool:helloworld />
            
        </body>
    
    </html>
    #215967 Reply

    glurps
    Member

    sidenote: when trying to preview my post i am taken to http://myeclipseide.com/index.php without any arguments.

    #215969 Reply

    Riyad Kalla
    Member

    Moving to Random Thoughts, this is a Java question.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: nullpointer for pageContext

You must be logged in to post in the forum log in