Hi there,
I tried to pass parameter values from JSP to a Servlet. The output from the
Servlet is displayed on the browser but the parameter values are null. Why
is this so?
-- JSP --
<%@ page language="java" %>
<%
String Username = "SUPER";
String Password = "TOMCAT";
%>
<%-- Forward to Servlet --%>
<jsp:forward page="servlets/WLL">
<jsp:param name="P_USERNAME" value="<%=Username%>" />
<jsp:param name="P_PASSWORD" value="<%=Password%>" />
</jsp:forward>
-- Servlet --
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class WLL extends HttpServlet
{
public void doGet (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter out;
// set content type and other response header fields first
response.setContentType("text/html");
// get request objects
String Username = request.getParameter("P_USERNAME");
String Password = request.getParameter("P_PASSWORD");
// then write the data of the response
out = response.getWriter();
out.println("<HTML><HEAD><TITLE>");
out.println("</TITLE></HEAD><BODY>");
out.println("Test Servlets from JSP <br>");
out.println("Username : " + Username + "<br>");
out.println("Password : " + Password + "<br>");
out.println("</BODY></HTML>");
out.close();
}
}
--
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets