wood burning stoves 2.0*
The moose likes Servlets and the fly likes Malformed Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Malformed Servlet" Watch "Malformed Servlet" New topic
Author

Malformed Servlet

shabbir zakir
Ranch Hand

Joined: Nov 12, 2000
Posts: 183
HI!
THe above code compiles properly but when i start my server it gives malformedValidatePinServlet and i can not start that servlet from my browser though my path is right. The code is as below
import java.io.*;
import java.net.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ValidateServlet extends HttpServlet
{
public static final String PREFIX = "ijs.session.login";
public static final String ACCOUNT = PREFIX + ".account";

public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
PrintWriter out = response.getWriter();
response.setContentType("text/html");

HttpSession session = request.getSession(true);
session.removeValue(ACCOUNT);
try{
String acctno = request.getParameter("acctno");
if(acctno == null)
throw new RuntimeException
("NO accopunt number was specified");
acctno = acctno.trim();
if(acctno.equals(""))
throw new RuntimeException
("Account number can not be blank");

String PIN = request.getParameter("PIN");
if(PIN == null)
throw new RuntimeException
("NO PIN number was specified");

PIN = PIN.trim();
if(PIN.equals(""))
throw new RuntimeException
("PIN number cannot be balnk");

if(!PIN.equals("4311"))
throw new RuntimeException
("Invalid PIN number");

Hashtable account = new Hashtable();
account.put("acctno",acctno);
account.put("PIN",PIN);
session.putValue(ACCOUNT,account);

StringBuffer buffer = new StringBuffer();

buffer.append("<H3>Welcome to ServletBank</h3>");
buffer.append("Please select from");
buffer.append(" the following options");
buffer.append("<ol>");
buffer.append("<LI>");
buffer.append("<A HREF=\"http://localhost:8080/examples/servlet/BalanceInquiry\"");
buffer.append(">Balance Inquiry</A>");
buffer.append("<L1>Transfer Funds");
buffer.append("(not available at the moment)");
buffer.append("<ol>");

out.println(buffer.toString());
}
catch(RuntimeException e)
{
StringBuffer buffer = new StringBuffer();

buffer.append("<H3>Welcome to ServletBank</h3>");
buffer.append("<PRE>\n");
buffer.append(e.getMessage());
buffer.append("\n");
buffer.append("</PRE>");
buffer.append("<P>");
buffer.append("Click");
buffer.append("<A href=\"");
buffer.append("/ijs/Chap07/login/GetAccountNumber.html\"");
buffer.append(">here</A>");
buffer.append(" to enter your account number.");

out.println(buffer.toString());
}
finally {
out.flush();
}
}

public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
doGet(request,response);
} }

Thanks in adavance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Malformed Servlet
 
Similar Threads
String Buffer Question
FOP Servlet - XSLTInputHandler error
Really in a hurry!
how to acces a remote servlet from a java client?????
Overriding the doPost method