• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

http status 404

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when i fill form and submit .its say The requested resource (/minipro/checcking) is not available
i have to complet my project please help to solve this problm

thanks inadvance.
update:

<html>
<body bgcolor=paleblue>
<center><br><br><br>
<form action="http://locahost:8090/minipro/checcking" >
<pre>user id :<input type=text name=id size=20>
</pre>
<input type=submit name=submit value=submit>
</center>
</body>
</html>

<web-app>
<servlet>
<servlet-name>checcking</servlet-name>
<servlet-class>checking</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>checcking</servlet-name>
<url-pattren>/checcking</url-pattren>
</servlet-mapping>
</web-app>



checcking:

import java.io.*;
import javax.servlet.*;
import java.sql.*;
import javax.servlet.http.*;
public class checcking extends HttpServlet
{
Connection con;

public void init(ServletConfig sc)throws ServletException
{
super.init(sc);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:odbms","system","oracle");
}catch(Exception e){ System.out.println(e);}
}

public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{

res.setContentType("text/html");
PrintWriter pw=res.getWriter();

String s1=req.getParameter("id");
if(s1==null|s1.equals(""))
{
pw.println("<body bgcolor=red>");
pw.println("<h1 align=left> error please enter user id...</h1>");
pw.println("<a href='update.html'><h3>click</h3></a>");
return;
}
try
{
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select userid from logindetails where userid=' "+s1+" ' ");
while(rs.next())
{
String s2=rs.getString(1);
String s3=rs.getString(2);
}
if(s1.equals("s2"))
res.sendRedirect("billdetails.html");
else
res.sendRedirect("fail.html");
}

billdetails.html

<html>
<head><center>
<h3>Enter user bills </h3>
</head></center>
<body bgcolor=lime>
<center>
<form action="http://localhost:8090/minipro/billdetails">
<pre>month :<select name=month>
<option value=January>January
<option value=Febrauay>Febrauay
<option value=March>March
<option value=April>April
<option value=May>May
<option value=June>June
<option value=July>July
<option value=August>August
<option value=September>September
<option value=October>October
<option value=November>November
<option value=December>December</select><br>
Current bill :<input type=text name=current size=20><br>
Phone bill :<input type=text name=phone size=20><br>
Net bill :<input type=text name=net size=20><br>
Water charges :<input type=text name=water size=20><br>
Maintainance :<input type=text name=maintain size=20><br>
<input type=submit name=sumbit value=submit>
</pre></td></tr></table></center></form></body></html>



catch(Exception e1){ System.out.println(e1);}
}
}

fail.html:

<html>
<body bgcolor=lime<br><br>
<center>
<h3>you entered wrong user id.</h3>
<a href="update.html">click here</a></center>
</body>
</html>
billdetails

import java.io.*;
import javax.servlet.*;
import java.sql.*;
import javax.servlet.http.*;

public class billdetails extends HttpServlet
{
Connection con;
public void init(ServletConfig sc)throws ServletException
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:odbms","system","oracle");
}catch(Exception ee){System.out.println(ee);}
}

public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException
{
String s1=req.getParameter("month");
String s2=req.getParameter("current");
String s3=req.getParameter("phone");
String s4=req.getParameter("net");
String s5=req.getParameter("water");
String s6=req.getParameter("maintain");

/*create table billdetails(month varchar(10),currentbill number(7),phonebill number(7),
netbill number(7),waterbill number(7),maintaincebill number(7)); */

try{
PreparedStatement pst=con.prepareStatement("insert into billdetails values(?,?,?,?,?,?)" );

pst.setString(1,s1);pst.setString(2,s2);pst.setString(3,s3);pst.setString(4,s4);
pst.setString(5,s5);pst.setString(6,s6);
pst.execute();

}
catch(Exception e)
{System.out.println(e);}
PrintWriter pw=res.getWriter();
res.setContentType("text/html");
pw.println("<B>inserted.into table..");
}
}

 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the ranch.

What container are you using?

WP
 
Ranch Hand
Posts: 343
Mac OS X Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please put your code in Code block. Edit your post to do so.

P.S.:- Not related to the solution of your query but related to Naming Convention, why the name of the Class (Servlet) in small? It should always be capital as per the standards.
)
 
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

Check your servlet class name in web.xml and the class name in your servlet class





It would be better if you follow MVC architecture. Separate persistence logic from servlet

There is a lots of error in your code. Check it properly.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


All classes used in servlets should be in a package - the reason being that the JVM looks for bare classes in the "current" directory - something you have no control over in the servlet environment.

Bill
 
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai..
It is not recommended to override the init(-) lifecycle method rather than you initialise your jdbc objects in init() method which is not life cycle and internally called by init(-).though you can use init(-) in your servlet program it is not recommended and also not industry standard..init() is not lifecycle method but is the convenience method given to programmer to place programmer choice initialization logics by overriding the iniit(-).
Servlet container doesn't call init() directly for instantaiation event.it is internally called by init(-).. if you verify the source code you can easily understand the various scenarios..





 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



<html>
<body bgcolor=paleblue>
<center><br><br><br>
<form action= "http://locahost:8090/minipro/checcking" >
<pre>user id :<input type=text name=id size=20>
</pre>
<input type=submit name=submit value=submit>
</center>
</body>
</html>


give the url patter of your servlet class.use relative url than using absolute url.. moreover please see that there are no spelling mistakes.. it is localhost not locahost.please also see that the deployment directory structure is correct before you run your applicaton.. your servlet program should reside in classes folder and html program inside web root folder parallel to WEB-INF. you get 404 status code when your deployment directory structure is wrong or when you give wrong url pattern at browser window.. please check it once.

try to change your for page as below:

<form action= "/checcking" >
<pre>user id :<input type=text name=id size=20>
</pre>
<input type=submit name=submit value=submit>
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That will not work. The action must start with the context path preceding the servlet path.
 
Greenhorn
Posts: 13
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<url-pattren>/checcking</url-pattren>

please check the spell of <url-pattren>

probably this can also be an issue.....
 
reply
    Bookmark Topic Watch Topic
  • New Topic