Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


Harshu
Programming
0 Answer(s)      4 years and 3 months ago
Posted in : JSP-Servlet


<%@ page language="java" import="java.sql.*" %>
<%@ page import="java.lang.String.*" %>
<%
Connection con=null;
//ResultSet state=null;
Statement stmt=null;
String st;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Advdsn");
stmt=con.createStatement();

}
catch(SQLException se)
{
out.println("Database Error:"+se.getMessage());
}
catch(Exception e)
{
e.toString();
}

%>
<HTML>
<HEAD>
<TITLE> Place Ad </TITLE>

<script language="text/JavaScript" >

function func()
{
var filename = document.form.img.value;
window.location.href=("http://localhost:8080/ProjectAd/Preview?

filename="+filename);
}
function Draft(){

if(document.form.DraftAd.value=="" || document.form.DraftAd.value==null)
{
document.form.cnt.value=0;}
else
{document.form.cnt.value = document.form.DraftAd.value.split(' ').length;}
}
</script>



</HEAD>

<BODY BGCOLOR="lightblue">
<marquee behavior="alternate" scrollamount=5 scrolldelay=10><h1><font size=4 face="Stroustroup" color="#993355">Advertisement Management System</h1></font></marquee><br>
<p align=center><b> <font color="669933" size=4>Create Ad </font></b></p><br>
<form name="form" action="http://locathost:8080/ProjectAd/Preview" method=post>
State: <select name="State" size=1>
<%
ResultSet state=stmt.executeQuery("Select * from PlaceAd where State is not null ");

while(state.next())
{
%>
<option>
<%
out.println(state.getString("State"));
%>
</option>
<%}%>
</select><br>

City: <select name="City" size=1>
<%
ResultSet city=stmt.executeQuery("Select * from PlaceAd where City is not null");
while(city.next())
{
%>
<option>
<%

out.println(city.getString("City")); %>
</option>
<%}%>
</select><br>
Main Category: <select name="mainCat" size=1>
<%
ResultSet mainC=stmt.executeQuery("Select * from PlaceAd where MainCategory is not null");
while(mainC.next())
{
%>
<option>
<%

out.println(mainC.getString("MainCategory")); %>
</option>
<%}%>
</select><br>
Sub Category:<select name="subCat" size=1>
<%
ResultSet subC=stmt.executeQuery("Select * from PlaceAd where SubCategory is not null");
while(subC.next())
{
%>
<option>
<%

out.println(subC.getString("SubCategory")); %>
</option>
<%}%>
</select><br>
Title: <input type=text name="Title" size=25 onkeyup="return Validate();"><br>

<p>Draft Your Ad Here:<textarea name="DraftAd" cols="15" rows="2" onkeyup="Draft();"></textarea>
<br>
<input name="cnt" type="text" value="" readonly>

<p>Image:<input type="file" name="img">
<!--<input type="button" name="c" value="Save">--></p>

Email:<input type=text name="Email" size=25><br>
Phone No:<input type=text name="PhoneNo" size=25><br>
Select Newspaper:<select name="NewsPaper" size=1>
<%
ResultSet newspaper=stmt.executeQuery("Select * from PlaceAd where NewsPaper is not null");
while(newspaper.next())
{
%>
<option>

<%

out.println(newspaper.getString("NewsPaper")); %>
</option>
<%}%>
</select><br>
Select Your Date:<select name="Date" size=1>

<%for (int date=1;date<=31;date++)
{
%>
<br><option>

<%out.println(date);
%>
</option>
<%}%>
</select>
Month:<select name="Month" size=1>
<%
for (int month=1;month<=12;month++)

{
%>
<option>
<%

out.println(month);
%>
</option>
<%}%>
</select>
Year:<select name="Year" size=1>
<%
for (int year=1960;year<=2010;year++)
{
%>
<option>
<%
out.println(year);
%>
</option>
<%}%>
</select><br>
Select Number of Days:<input type=text name="Days" size=5><br>
<!--<p>Confirm:<input type=checkbox name=confirm ></p>-->
<input type="button" name="c" value="Save" >
<br>
<p><input type=button name=submit value=Submit onClick="func();"><br>

</form>
</BODY>
</HTML>

I want that all this value should get displayed on next page as preview along with selected image
and when i click on save it should get save in access database and when i click on submit it should get displayed on next page and in script the Draft () function is not working and there is some problem in this code.

Code for Preview:

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

public class Preview extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
//HttpSession hs=req.getSession(true);
//String count=req.getParameter("cnt");
//hs.putValue("Count",count);

//File file=new File(f);
//FileInputStream in=new FileInputStream(file);

out.println("<html><body bgcolor=lightblue>");
out.println("<font align=center size=5 color=Green>Preview</font><br>");
out.println("</body></html>");

String title=req.getParameter("Title");
out.println(title+"<br>");
String f=req.getParameter("filename");
out.println(f+"<br>");
String st=req.getParameter("State");
out.println("<p align=center>"+st+"<br>");
String ct=req.getParameter("City");
out.println(ct+"<br>");
String mc=req.getParameter("mainCat");
out.println(mc+"<br>");
String sc=req.getParameter("subCat");
out.println(sc+"<br>");
String da=req.getParameter("DraftAd");
out.println(da+"<br>");
String count=req.getParameter("cnt");
out.println(count+"<br>");
String np=req.getParameter("NewsPaper");
out.println(np+"<br>");
String dt=req.getParameter("Date");
out.println(dt+"-");
String mth=req.getParameter("Month");
out.println(mth+"-");
String y=req.getParameter("Year");
out.println(y+"<br>");
String days=req.getParameter("Days");
out.println(days+"<br>");
out.println("<a href=\"http://localhost:8080/ProjectAd/Payment.jsp\">Payment</a>");
}
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{doPost(req,res);}
}

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Programming
Programming  Given a number n, write a programming to determine its square root if it is possible, in the contraly case print an appropriate massege on the screen
programming
Java Constructor programming for single and double constructor  write a program which have no argument constructor ,single parameter constructor constructor,double parameter constor,and the now when we create a object
Advertisements
Programming
Java NotesProgramming Here are some tips on making programming student problems easier. Start from an existing, running, program. If you can find... of the basic elements of Extreme Programming (a much hyped, but good
Programming with JSP
Programming with JSP  Who will post me the answer
Java Programming
Java Programming  Hi, What is Java Programming? How I can learn Java Programming in one month? Thanks
Ajax programming
Ajax programming  Hi, How I can start ajax programming easily? I... concept. What should be my starting point for Ajax programming? Thanks   Hi, If you have prior programming experience in any web development
Programming with JSP
Programming with JSP  Write a program using jsp that accepts a course code as input and displays the course title the program to which it belongs
Programming (general)
Programming (general)  I haven't yet started college/university but I'm interested in studying programming. I wondering if programming is difficult or confusing with all the codes you have to learn? Also how many languages would
programming of foxpro
programming of foxpro  hello sir , sir i am use the foxpro . but i know about c . sir how can i learn fox pro . i know about something about foxpro
programming concept
programming concept  Write a program that allows the user to input a total dollar amount for an online shopping order and computes and outputs the shipping cost based on the following schedule
Socket Programming
Socket Programming  How to connect a computer through IP only and check whether it is up and running? I can't see any method in Socket programming where I can pass only IP address as argument. I need the pass port number also
programming error
programming error  I got an error when i did the following program the prg. is to "select the name from database when the age is given for the respective name" error i got is:SQL exception please give me the solution by providing
C Programming
C Programming  hi,how can i write a program in C programming to place reservation in air plane from the menu let the user to inter his/her gender(W or M)and draw seats by using ascii codes and choose where he/she will sit
programming c#
programming c#   create and make use of at least one class with appropriate instance methods to solve the programming problem. use console-based menus to navigate between the functionality offered by the application. at least one
Programming Assignment
Programming Assignment  Hey there, We were given an assignment to write a program to read 10 student marks from the keyboard without using an Array (only using switch statements, if statements or loops). As each mark is input
programming questions
programming questions  this is my assignment questions please help me... the programs in c# language Describe the following with respect to creating Web Forms in .Net environment: a. Web Form Life Cycle b. Creating a Web Form
ajax programming
Ajax Programming What is Ajax Programming? Asynchronous JavaScript and XML... is based on the HTML, Java Script, CSS, and XML. Why Ajax Programming? When you.... Easy to learn and easy to write technology. Where to Start Ajax Programming
programming problem
programming problem   Kingdom of Maplewood is a beautiful country comprising of a lot of small islands of different areas. All the islands are in a straight row. King Rosewood is getting old and has decided to divide the islands
Java Programming
Java Programming  Write a Java program that prompt user to input a number of students in a class. Then, prompt user to input the student√?¬Ę√Ę‚??¬¨√Ę‚??¬Ęs programming mark. Determine how many student get A+ and A for their grade
java programming
java programming  Write a Java program that prompt user to input a number of students in a class. Then, prompt user to input the student‚??s programming mark. Determine how many student get A+ and A for their grade and how many
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 9.4 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook. Exercise 9.4: The file Expr.java defines a class, Expr, that can be used
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 9.3 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook. Exercise 9.3: A Roman numeral represents an integer using letters. Examples
programming - Java Beginners
programming for java beginners  How to start programming for java beginners
What is programming logic ?
What is programming logic ?  What is programming logic
programming - Java Beginners
Start programming in Java  Programming in Java - Can any one please suggest how to start programming in Java
object oriented programming protocol
object oriented programming protocol  What is object oriented programming protocol? Is it different from objective c protocol programming?? Thanks
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 2.1 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook. Exercise 2.1: Write a program that will print your initials to standard output
Java Programming, Solution to Programming Exercise
Solution for Programming Exercise 12.4 THIS PAGE DISCUSSES ONE.... Some languages use predicates in generic programming. Java doesn't... as a standard part of the generic programming framework.) Discussion
Programming - JSP-Servlet
Programming jsp servlet   Couple of examples that can help to start programming jsp servlet
programming - Java Beginners
How to programming in Java  How to start programming in Java? Please provide me the step by step guide.Thanks
What is attribute oriented programming?
What is attribute oriented programming?  Hi, What is attribute oriented programming? Thanks
Java Programming, Solution to Programming Exercise
Solution for Programming Exercise 12.1 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... generic programming framework, and it is defined in terms of Vectors rather than
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 2.3 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook. Exercise 2.3: Write a program that asks the user's name, and then greets
 

 

 

DMCA.com