Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

viral patel

Greenhorn
+ Follow
since Feb 25, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by viral patel

Can anyone show me how to write Swap funtion in java. I tried but its not working properly.COde will be help lot.
18 years ago
Im trying to insert data to my Accounts table. I have Created AccountId_sequence to generate accountID. I'm getting data from a form and and storing in database.Here how i'm trying to insert new data with sequence, but its not updating table. Can someone show me right way to do this.
Hi..I have jsp page call sucess.jsp. which is basically get data from a form and stors in database. In my all table i created Sequences to generate accountID and stuff. Now when write my sql query..for example:
Insert into('"+accountId_sequence.NEXTVAL+"','"+viral+"'...);
it gives me error that it can find variable call accountID_squence...
SO my question is how can i store data from a form using Sequence from jsp page..
18 years ago
JSP
i done that it is still giving me error that it cant find AccountBean..
18 years ago
JSP
I have this New user registration form. I user AccountBean to store data from a form. and check make sure all fields are fill. and process.jsp use that bean..and send to retry.jsp or to success.jsp..I also put both AccountBean.java and Its .class file in WEB-INF class folder but its going to this error:
HTTP ERROR: 500 Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated. An error occurred at line: 2 in the jsp file: /jsp/ac/process.jsp Generated servlet error: /var/tmp/Jetty_0_0_0_0_8888__group24_j2ee/jsp/ac/process$jsp.java:61: Class org.apache.jsp.AccountBean not found. AccountBean formHandler = null; ^ An error occurred at line: 2 in the jsp file: /jsp/ac/process.jsp Generated servlet error: /var/tmp/Jetty_0_0_0_0_8888__group24_j2ee/jsp/ac/process$jsp.java:64: Class org.apache.jsp.AccountBean not found. formHandler= (AccountBean) ^ An error occurred at line: 2 in the jsp file: /jsp/ac/process.jsp Generated servlet error: /var/tmp/Jetty_0_0_0_0_8888__group24_j2ee/jsp/ac/process$jsp.java:69: Class org.apache.jsp.AccountBean not found. formHandler = (AccountBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "AccountBean"); ^ 3 errors, 1 warning

18 years ago
JSP
i found the problem..but thank for anyway
18 years ago
JSP
Hi,
Im trying to process data from a form. I have java bean. And method call validata(). whicj check if any required field is empty.if it its then it send to retry.jsp page. Otherwise send to success.jsp. When i try to use it..it give me erroe saying
HTTP ERROR: 500 /jsp/ac/process.jsp(16,32) Attribute )% has no value
I dont know what is wrong here.
can someone help me here.
Here my code
Process.jsp
<%@ page import="java.util.*" %>
<%!
ResourceBundle bundle =null;
public void jspInit() {
bundle = ResourceBundle.getBundle("forms");
}
%>
<jsp:useBean id="formHandler" class="foo.FormBean" scope="request">
<jsp:setProperty name="formHandler" property="*"/>
</jsp:useBean>
<%
if (formHandler.validate()) {
%>
<jsp:forward page="sucess.jsp")%>"/>
<%
} else {
%>
<jsp:forward page="retry.jsp"/>
<%
}
%>
My bean code:
package foo;
import java.util.*;
public class FormBean {
private String userName;
private String password;
private String firstName;
private String lastName;
private String cName;
private String cAddress;
private String city;
private String state;
private String zipCode;
private String phone;
private String fax;
private String email;
private Hashtable errors;
public boolean validate() {
boolean allOk=true;
if (userName.equals("")) {
errors.put("userName","Please enter your User name");
userName="";
allOk=false;
}
if (password.equals("") ) {
errors.put("password","Please enter a valid password");
password="";
allOk=false;
}
if (firstName.equals("")) {
errors.put("firstName","Please enter your first name");
firstName="";
allOk=false;
}
if (lastName.equals("")) {
errors.put("lastName","Please enter your last name");
lastName="";
allOk=false;
}
if (cName.equals("")) {
errors.put("cName","Please enter your Company name");
cName="";
allOk=false;
}

if (cAddress.equals("")) {
errors.put("cAddress","Please enter your address");
cAdress="";
allOk=false;
}

if (city.equals("")) {
errors.put("city","Please enter your city name");
city="";
allOk=false;
}
if (state.equals("")) {
errors.put("state","Please enter your state name");
state="";
allOk=false;
}
if (zipCode.equals("") || zipCode.length() !=5 ) {
errors.put("zipCode","Please enter a valid zip code");
zipCode="";
allOk=false;
} else {
try {
int x = Integer.parseInt(zip);
} catch (NumberFormatException e) {
errors.put("zipCode","Please enter a valid zip code");
zipCode="";
allOk=false;
}
}
if (phone.equals("")) {
errors.put("phone","Please enter valid Phone number");
phone="";
allOk=false;
}
if (fax.equals("")) {
errors.put("fax","Please enter your fax number");
fax="";
allOk=false;
}
if (email.equals("") || (email.indexOf('@') == -1)) {
errors.put("email","Please enter a valid email address");
email="";
allOk=false;
}

return allOk;
}
public String getErrorMsg(String s) {
String errorMsg =(String)errors.get(s.trim());
return (errorMsg == null) ? "":errorMsg;
}
public FormBean() {
userName="";
password="";
firstName="";
lastName="";
cName="";
cAddress="";
city="";
state="";
zipCode="";
phone="";
fax="";
email="";
errors = new Hashtable();
}
public String getUserName() {
return userName;
}
public String getPassword() {
return password;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public String getCName() {
return cName;
}
public String getCAddress() {
return cAddress;
}
public String getCity() {
return city;
}
public String get State() {
return state;
}
public String getZipCode() {
return zipCode;
}
public String getPhone() {
return phone;
}
public String getFax() {
return fax;
}
public String getEmail() {
return email;
}
public void setUserName(String u) {
userName=u;
}
public void setPassword(String p) {
password=p;
}
public void setFirstName(String fname) {
firstName =fname;
}
public void setLastName(String lname) {
lastName =lname;
}
public void setCName(String company) {
cName =company;
}
public void setCAddress(String address) {
cAddress =address;
}
public void setCity(String c) {
city =c;
}
public void setState(String s) {
state =s;
}
public void setZipCode(String z) {
zipCode=z;
}

public void setPhone(String ph) {
phone=ph;
}
public void setFax(String f) {
fax=f;
}
public void setEmail(String eml) {
email=eml;
}
public void setErrors(String key, String msg) {
errors.put(key,msg);
}
}

18 years ago
JSP
Hello, I have login form, where user provides username and password. Then click on submit, it will forward to validation.jsp. Where it will check in database make sure username and password exit. Now i can also retrive accountid of perticular user. I want to put that username and accountid in session scope. so all other pages can use that username and accountid. How can i do that. I'm new at this, so please provide me example too. Here is my code for login.jsp and validation.jsp..
Validation.jsp
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
//String name = request.getParameter( "username" );//
//session.setAttribute( "accountID",accountID );//
<%
String connURL = "jdbc racle:thin:@orca.csc.ncsu.edu:1521 RCL";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
conn = DriverManager.getConnection(connURL, "vapatel","pjdas");
stmt = conn.createStatement();

String user=request.getParameter("userName");
String password=request.getParameter("password");
boolean entrance=false;
stmt.excuteQuery("SELECT AccountID From Password WHERE USERNAME='"+user+"'");
rs = stmt.executeQuery("SELECT * FROM Password WHERE USERNAME='"+user+"' AND PASSWORD='"+password+"'");
while(rs.next()){
String dbUser = rs.getString("USERNAME");
String dbPassword= rs.getString("PASSWORD");
if ((user.equals(dbUser)) && (password.equals(dbPassword))){
entrance=true;
}
}
if (entrance==true){%>
<jsp:forward page="form.jsp"/>
<%}
else{%>
<jsp:forward page="login.jsp"/>
<%}
%>
}
18 years ago
JSP
Basically, i need to send my xml documents to servlets from jsp. How do i post jsp request to servlets. so then in servlets i can use..request.getparameter()..something like that..
18 years ago
JSP
i'm generating xml inside my jsp page, now i want to send that xml to servlets using that same jsp page.. Can i do that, if i can how. can some one show me example how to do it..
18 years ago
Hi...I have orderform, i user orderbean to store data entered in orderform. Now i want to generate xml in jsp using my orderbean. Can i do that. and if i can...can someone show me example how?
18 years ago
JSP
I have application where user can login and order product from online. I want to create session so in my login page, so once they login, all other pages will know who is login. And perform according to that. Can someone show me how can i use session for that.
18 years ago
JSP
can i excute multiple query in jsp page to fill database. If i can, can you give me example of it.
thanks
18 years ago
JSP
Hi...I have orderform, i user orderbean to store data entered in orderform. Now i want to generate xml in jsp using my orderbean. Can i do that. and if i can...can someone show me example how?
18 years ago
JSP
Can i execute more then on sql queries in one JSP page. If i can how can i do that.
18 years ago
JSP