This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

servlet not found

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,I have an HTML page;the chosen values from this page has to be retrieved by a servlet;this code was working fine a few months ago..but now when I say servletrunner -d part6\RAF,where part6 is the folder& RAF is the servlet in this folder..on c:
I get an error message saying servlet not found ..
the HTML form's code is below:<html>
<head>
<title>enquiry.html</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body text="#339966" link="#3333FF" vlink="#FF6666" alink="#CC9933">
<p><font size="+3"><u>SURVEY</u></font> </p>
<form method="post" action="http://localhost:8080/servlet/RAF">
<p><legend>Enter your details correctly</legend><b><br>
<font face="Arial, Helvetica, sans-serif" size="+1">Q1.I would like to know
if anybody in your family is using any of these products?</font></b>
<select name="q1" >
<option value="3">SHAMPOO</option>
<option value="2">TOOTH PASTE</option>
<option value="3">TOILET SOAPS</option>
<option value="4">SKIN CREMA/LOTIONS</option>
</select>
</p>

<font face="Arial, Helvetica, sans-serif" size="+1">Q2.I would like to know
if anybody in your family is using any of these products?</font></b>
<select name="q2" >
<option value="27">SKIN CREMA/LOTIONS</option>
<option value="2">TOOTH PASTE</option>
<option value="3">TOILET SOAPS</option>
<option value="4">SHAMPOO</option>
</select>
</p>
<font face="Arial, Helvetica, sans-serif" size="+1">Q3.I would like to know
if anybody in your family is using any of these products?</font></b>
<select name="q3" >
<option value="999">SKIN CREMA/LOTIONS</option>
<option value="3">TOILET SOAPS</option>
<option value="4">SHAMPOO</option>
</select>
</p>
<p><b><font face="Arial, Helvetica, sans-serif" size="+1">Submit:
<input type="submit" value="Submit">
Reset:
<input type="reset" value="Reset">
</font></b>

</form>
</body>
</html>
& the servlet code is:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import java.util.StringTokenizer;
public class RAF extends HttpServlet{
int count,i,k,j,l,a;
String Q,q,str,string,Str,S;
StringBuffer sb = new StringBuffer();
StringBuffer smb = new StringBuffer();
PrintWriter pw,out;
StringTokenizer qstk;
public void init(ServletConfig config) throws ServletException{
super.init(config);
}
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException
{
response.setContentType ("text/html");
PrintWriter out = response.getWriter();
out.println ("<html>");

out.println("<body>");

PrintWriter pw = new PrintWriter (new FileWriter ("c:/part6/ Textfile.txt " ,true) , true );
Enumeration enum = request.getParameterNames();

out.println("thank you for your response");
while(enum.hasMoreElements())
{
Q = (request.getParameter((String) enum . nextElement()));

q += (";"+Q);

}
sb = new StringBuffer(q);
sb.delete(0,5);
q = sb.toString();

StringTokenizer qstk = new StringTokenizer(q,";");
while(qstk.hasMoreTokens())
{
str = qstk.nextToken();
count++;
}



smb.setLength(100);
for(int i =0;i<100;i++)
{
smb.insert(i,0);
}

BufferedReader bf = new BufferedReader( new FileReader("c:/part6/pos.txt "));
while((Str=bf.readLine()) != null)
{
StringTokenizer st = new StringTokenizer(Str,";");

while(st.hasMoreTokens())
{

String Q = st.nextToken();
out.println("Q = "+Q);
String R = st.nextToken();
out.println("R = "+R);
l = Integer.parseInt(R);
String P = st.nextToken();
j = Integer.parseInt(P);
a = (j+(l-1));
out.println("P = "+P);
k = 0;
qstk = new StringTokenizer(q,";");


while(k<count)
{
qstk.hasMoreTokens();
str = qstk.nextToken();
k++;
}

count--;

smb.replace(j,(j+l),str);
//out.println("the smb string is = "+smb);

}

}
pw.println(smb);
pw.close();
out.println("</body> </html>");
out.close();

} // dopost()

} //end.

Can someone help?
Is the command to invoke the servlet correct?
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your command is ok but you should be sure that your servlet RAF.class is in the servlets dir of your web server
vikas
 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!