Hi everybody,

I have an input form in XML/XSL (radio buttons and a text field). I'm
using the JSDK WebServer 2.1 for the servlets and the MS Personal Webserver for
static pages on Windows NT (JDK 1.2 and JSDK 2.1) and IE5.
After pressing the "Submit" button I can see the "Servlet: init" line in
the DOS box of the JSDK WebServer. But in the Webbrowser I get a nullpointer
exception:

Error: 500
Internal Servlet Error:

java.lang.NullPointerException
        at NewTypeServlet.doPost(NewTypeServlet.java:93)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:747)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
        at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:140)
        at com.sun.web.core.InvokerServlet.service(InvokerServlet.java:169)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
        at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:140)
        at com.sun.web.core.Context.handleRequest(Context.java:375)
        at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:135)


My doPost method contains the following lines:

...

String inputTextValue = new String("");
String inputRadioValue = new String("");

...

public void doPost(HttpServletRequest request,
                HttpServletResponse response)
                throws ServletException, IOException
{
        // get parameter values from client

        // Text value of the new data type
        inputTextValue = request.getParameter("NewType");


        // Radio buttons
        inputRadioValue = request.getParameter("AdmInsertSelect");

        ...
}

NewType is the name text field in my input form and AdmInsertSelect is the
name of the radiobutton group.
Both the inputTextValue and the inputRadioValue are null, no matter what I
enter or select in the form before.
And now I don't know why I just get null for all the form parameters. When
I use a normal HTML form for the input, the values are correct, there is no
exception.
Can anybody tell me if that is a servlet problem or if it is an xml
problem. Or even better: Can anybody tell me what exactly the problem is when I'm
using forms in xml and servlets?

Thanks for your help!
Helge


In case it helps you, here the code of the XML file (or at least the
important part of it):

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="../start.xsl" type="text/xsl" ?>

<Webpage>
        <InputForm>
                <Radiobutton Name="AdmInsertSelect" Value="NewApp" Text="Enter a new
application"/>
                <Radiobutton Name="AdmInsertSelect" Value="NewObj" Text="Enter a new
object"/>
                <Radiobutton Name="AdmInsertSelect" Value="NewEvt" Text="Enter a new
event type"/>
                <Radiobutton Name="AdmInsertSelect" Value="NewReact" Text="Enter a new
reaction type"/>
                <Radiobutton Name="AdmInsertSelect" Value="NewParam" Text="Enter a new
reaction parameter type"/>

                <TextInput Name="NewType" Size="40" MaxChar="750" Text="Enter the new
value: "/>

                <OkButton/>
                <ResetButton/>

        </InputForm>
</Webpage>


and the XSL file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="/">
        <HTML>
        <BODY>
                <xsl:apply-templates select="Webpage/InputForm"/>
        </BODY>
        </HTML>
</xsl:template>

<xsl:template match="InputForm">
        <FORM  Action="http://localhost:8080/servlet/NewTypeServlet"
Method="POST">

                <BR/>
                <xsl:apply-templates select="Radiobutton"/>
                <xsl:apply-templates select="TextInput"/>
                <xsl:apply-templates select="OkButton"/>
                <xsl:apply-templates select="ResetButton"/>
                <BR/>
        </FORM>
</xsl:template>


<xsl:template match="Radiobutton">

        <Input type="radio">
                <xsl:attribute name="name">
                        <xsl:value-of select="@Name"/>
                </xsl:attribute>

                <xsl:attribute name="value">
                        <xsl:value-of select="@Value"/>
                </xsl:attribute>
        </Input>

        <xsl:value-of select="@Text"/>
        <BR/>
</xsl:template>

<xsl:template match="TextInput">
        <xsl:value-of select="@Text"/>

        <Input type="text">
                <xsl:attribute name="name">
                        <xsl:value-of select="@Name"/>
                </xsl:attribute>

                <xsl:attribute name="size">
                        <xsl:value-of select="@Size"/>
                </xsl:attribute>

                <xsl:attribute name="maxlength">
                        <xsl:value-of select="@MaxChar"/>
                </xsl:attribute>
        </Input>
</xsl:template>


<xsl:template match="OkButton">
        <Input type="submit" value="   Ok   "/>
</xsl:template>


<xsl:template match="ResetButton">
        <Input type="reset" value="Clear Form"/>
</xsl:template>


</xsl:stylesheet>

--
Sent through GMX FreeMail - http://www.gmx.net

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to