hi all,
I have my code below and Im not sure for what reason it isnt working! I did change my web.xml in the WEB-INF directory as well to contain the
servlet name and the init-param and its corresponding values. However when
I try running the servlet....it gives the 404 error.
I have the code and the web.xml extract below...
//code
package coreserv;
//imports
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class InitParams extends HttpServlet implements SingleThreadModel{
private
String message;
boolean debug;
private int repeats = 1;
private String defaultMessage = "No Message";
public void init() throws ServletException{
message = getInitParameter("message");
if(message==null){
message = defaultMessage;
}
try{
String repeatString = getInitParameter("repeats");
repeats = Integer.parseInt(repeatString);
}catch(NumberFormatException nfe){
}
}
public void toGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "The Message shown:";
out.println(ServletUtilities.HeadWithTitle(title) + "<BODY><H1>" + title + "</H1>");
for(int i=0;i<repeats;i++){
out.println(message + "<BR>");
}
out.println("</BODY></HTML>");
}
}
//web.xml...from /examples/WEB-INF/web.xml
<servlet>
<servlet-name>
InitParams
</servlet-name>
<servlet-class>
coreserv.InitParams
</servlet-class>
<init-param>
<param-name>message</param-name>
<param-value>Shibboleth</param-value>
</init-param>
<init-param>
<param-name>repeats</param-name>
<param-value>5</param-value>
</init-param>
</servlet>
and I type in
http://localhost:xxxx/examples/servlet/InitParams or
http://localhost:xxxx/examples/servlet/coreserv.InitParams both dont work..... :-(
I also tried this in init(ServletConfig config){} method as well...but no luck!!!
any suggestions?
any suggesstions....