tejaswini vasist

Greenhorn
+ Follow
since Apr 10, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by tejaswini vasist

Can anyone give me the logic as to how a program can delete itself?
20 years ago
What is the difference between Servlets and JSP?
20 years ago
I would like to know the length of an entire SOAP object and the number of bytes of header, body, envelope etc.
20 years ago
We have done the web service deployment successfully.All the classes of
the web service module is present in :
..\Tomcat\webapps\axis\WEB-INF\classes

The other part which has the admin login flow is present in :
..\Tomcat\webapps\onjava\WEB-INF\classes\com\onjava

We need to call the web service part from admin flow.We have given an
option for that.
We need to know what package or import statement has to be given.
1. ..\Tomcat\webapps\axis\WEB-INF\classes is in classpath
2. we tried calling ProjectClient(a class in
..\Tomcat\webapps\axis\WEB-INF\classes) from a java file in
..\Tomcat\webapps\onjava\WEB-INF\classes\com\onjava but it is giving an
error saying cannot resolve symbol Class ProjectClient.
20 years ago
hi,
i have this wholesaler deployment that im doing.In the beanservice i connect to the database and store the order there.But everytime i get this exception:No suitable driver found.The database access in the other files work perfectly except beanservice.
This is my code:
public class ProjectBeanService1
{
public String processProject1(Order order) throws Exception
{
String insertQuery = new String();
ResultSet rsb = null;
Statement stmtb = null;
Connection conb=null;
Connect ctb = new Connect();
try
{
conb= ctb.getConnection();
}
catch(Exception e)
{
System.out.println("connection exception");
}
try
{
insertQuery = "insert into samsung values('";
insertQuery = insertQuery + order.getItemName() + "',";
insertQuery = insertQuery+ order.getQuantity()+")";
System.out.println("insertquery" +insertQuery);
stmtb = conb.createStatement();
stmtb.executeUpdate(insertQuery);
System.out.println("Inserted");
}
catch(Exception e)
{
System.out.println("Sorry !!! Unable to insert");
System.out.println(e.getMessage());
}

int bool=0;
int repint=0;
String rep=new String();
String sep = System.getProperty("line.separator");
String response = "\n\nHi, " + "!" + sep;
String dealerName = new String();
int quant = 0;
response += sep + "From Samsung wholesaler" + sep+"\t\t******";
response += sep +" : We are processing your order of "+order.getQuantity();
response += " items of " + order.getItemName();
System.out.println("beanservice1 : "+response);
System.out.println("service 111 : "+response);
stmtb.close();
rsb.close();
return response;
}
}
Is there something im supposed to do if i have to access the database here?
I have used Tomcat4.0, Axis(i dont remember the version), Jdk1.4, MYSql database
I am implementing web services which takes an object & returns another object.

Problem is that I am unable to retrieve the return object properly. It is not even giving any errors.
I have 5 files. I have attached the files & I think that the problem is either in the file ProjectClient or in deploy.wsdd

It is giving details about the items in the database properly in Admin.java (the one that is shown in output document).But when it receives the object in a variable named result, it is printing null values.
Can you please tell me where I am going wrong.

ProjectClient.java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.apache.axis.AxisFault;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.utils.Options;
import java.io.*;
import java.lang.*;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
public class ProjectClient
{
public static void main(String [] args) throws Exception
{
DataInputStream in = new DataInputStream(System.in);
String username=new String();
String password = new String();
Options options = new Options(args);
Admin admin = new Admin();
DisplayItems result = new DisplayItems();
System.out.print("Enter admin username : ");
username = in.readLine();
admin.setUserName(username);
System.out.print("\nEnter admin password : ");
password = in.readLine();
admin.setPassword(password);

Service service = new Service();
Call call = (Call) service.createCall();
QName qn = new QName( "urn:BeanService", "Admin" );
QName qn1 = new QName( "urn:BeanService1", "DisplayItems" );
call.registerTypeMapping(Admin.class, qn,
new org.apache.axis.encoding.ser.BeanSerializerFactory(Admin.class, qn),
new org.apache.axis.encoding.ser.BeanDeserializerFactory(Admin.class, qn));
call.registerTypeMapping(DisplayItems.class, qn1,
new org.apache.axis.encoding.ser.BeanSerializerFactory(DisplayItems.class, qn1),
new org.apache.axis.encoding.ser.BeanDeserializerFactory(DisplayItems.class, qn1));
try
{
call.setTargetEndpointAddress( new java.net.URL(options.getURL()) );
call.setOperationName( new QName("OrderProject", "processProject") );
call.addParameter( "arg1", qn, ParameterMode.IN );
call.setReturnType( qn1 );
result = (DisplayItems) call.invoke( new Object[] { admin } );
}
catch (Exception e)
{
System.out.println("Error : " + e.getMessage());
}
for(int i=0;i<5; i++)
{
System.out.println(result.ItemName[i]+" "+result.ThresholdQuantity[i]+" "+result.QuantityRemaining[i]+" " +result.WholesalerID[i]);
}
System.out.println(result);
}
}

deploy.wsdd
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

<service name="OrderProject" provider="java:RPC">

<parameter name="className" value="ProjectBeanService"/>
<parameter name="allowedMethods" value="*"/>

<beanMapping qname="myNS:Admin" xmlns:myNS="urn:BeanService"
languageSpecificType="java:Admin"/>
<beanMapping qname="myNS isplayItems" xmlns:myNS="urn:BeanService1"
languageSpecificType="java isplayItems"/>
</service>
</deployment>
20 years ago
I have 3 buttons in my JSP.The servlet should capture the request and depending upon which button is pressed it should call a different jsp.
How can it be done?
i have a jsp which retieves an object and displays its contentsin the page.
The servlet written wil set the object values.I hav given print statements in the servlet.The output of which is correct and shows in Tomcat.But however the jsp doesnt show the same items even though i am retieving the same object and displayin it.What could be the problem?
jsp code:
<% DisplayItems items = new DisplayItems();
int numberOfItems=0;
String value = new String();
value = (String)request.getAttribute("NUMBER");
numberOfItems = Integer.parseInt(value);
items = (com.onjava.DisplayItems)request.getAttribute("ITEMS");
System.out.println("In jsp : " +numberOfItems);
try {
for (int j=0; j<numberOfItems; j++)
{
%>



<tr>

<td bgcolor=lightsteelblue><font face="verdana, arial, helvetica" size="2" width="20%"> <%=items.ItemID[j]%> </td>
<td bgcolor=lightsteelblue><font face="verdana, arial, helvetica" size="2" width="20%"> <%=items.ItemName[j]%> </td>
<td bgcolor=lightsteelblue><font face="verdana, arial, helvetica" size="2" width="20%"> <%=items.Quantity[j]%> </td>
</tr>
servlet code:
while(i<(vectorSize))
{
intElement = Integer.parseInt(listArray[i]);
try
{
conn= ct.getConnection();
}
catch(Exception e)
{
System.out.println("connection exception");
}
try
{
query = "select ItemID, ItemName, Price, QtyRemaining from Item where ItemID = '";
query = query + vect.elementAt(i) + "'";
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
while(rs.next())
{
ItemID=rs.getInt("ItemID");
ItemName=rs.getString("ItemName");
Price=rs.getFloat("Price");
QtyRemaining=rs.getInt("QtyRemaining");
/*QtyRemaining=rs.getInt("QtyRemaining");
ThresholdQuantity=rs.getInt("ThresholdQuantity");*/
System.out.println(ItemID+"\t"+ItemName+"\t\t\t"+Price+"\t"+quantityArray[k]);
size = rs.getRow();
item.setItemID(ItemID);
item.setItemName(ItemName);
item.setPrice(Price);
item.setQuantityRemaining(QtyRemaining);
/*item.setThresholdQuantity(ThresholdQuantity);*/
dispitems.ItemID[k] = ItemID;
dispitems.ItemName[k] = ItemName;
dispitems.Quantity[k] = Integer.parseInt(quantityArray[k]);

System.out.println("***************************");
System.out.println("itemid:" + dispitems.ItemID[k]);
System.out.println("itemname:" + dispitems.ItemName[k]);
System.out.println("quant:" + dispitems.Quantity[k]);
} //end of while
the output of these print statements are correct but in jsp they show diff values.
the below code is a part of my dopost method:
DisplayItems dispitems1 = new DisplayItems();
SelectItems selitem = new SelectItems();

try
{
dispitems1 = selitem.dispSelectedItems(vect,quant);
}
catch(Exception e)
{
System.out.println("vector problem" + e.getMessage());
}


//Integer IntVal = new Integer(vectorSize1);
String str1=new String();
str1=Integer.toString(stcnt);
request.setAttribute("NUMBER", str1);
request.setAttribute("ITEMS", dispitems1);

// Forward the request to the target named
ServletContext context = getServletContext();
RequestDispatcher dispatcher =
context.getRequestDispatcher(target);
dispatcher.forward(request, response);
}
here i catch the object and convert it into response.
20 years ago
JSP
I have a JSP in which the text boxes are generated based on the no of items present in the database.How do i make the name of each text box unique.Also how do i retrieve the values of these text boxes in the servlet .
My JSP code is :

try {
for (int i=0; i<numberOfItems; i++)
{
%>
<tr>

<td bgcolor=lightsteelblue><font face="verdana, arial, helvetica" size="2" width="20%">
<input type="hidden" name="id"+ i> <%=items.ItemID[i]%> </td>
<td bgcolor=lightsteelblue><font face="verdana, arial, helvetica" size="2" width="20%"><%=items.ItemName[i]%></td>
<td bgcolor=lightsteelblue><font face="verdana, arial, helvetica" size="2" width="20%"><%=items.Price[i]%></td>
<td bgcolor=lightsteelblue><font face="verdana, arial, helvetica" size="2" width="20%">
<input type="text" name="quant" + i maxlen=3 visibility="false"></td>
</tr>
<% }
} catch(Exception e)
{
System.out.println(e.getMessage());
}
%>

Is the syntax correct ? Also i want to know how to get these values in
the servlet.
20 years ago
JSP
Hi,
I have a login page..this calls a servlet for processing,then it loads another JSP page say welcome page..this again has to call another servlet which in turn has to load another JSP.But after the welcome page..it gives me server error ..the path seems to have an additional /servlet
i call the servlets as
action:servlet/package name.servlet-class name

Any idea wot the problem is?
20 years ago
JSP
My java classes are in ..\Tomcat 4.1\webapps\onjava\WEB-INF\classes\com\onjava
My jsp's are in ..\Tomcat 4.1\webapps\onjava
I actually need to call a java class from jsp which inturn returns an object. I am just unable to retrieve that object. I guess the problem is with the import statement which I have given inside the jsp.
I tried giving
<%@ page import = "WEB-INF.classes.com.onjava.*"
%>
& also
<%@ page import = "com.onjava.*"
%>
The error is HTTP Status 500.
20 years ago
JSP
Hi,
Im using Tomcat 4.1 and Mysql.
We have a servlet which collects the information from the database, stores 3 set of individual arrays in one object & returns the same. We need to capture this & display the contents of the individual arrays in the jsp. How do we do it ?
Any links that give examples as to how to get info from database into JSP?
20 years ago
JSP
Thanks a lot every one..i got the hang of it.
I have another doubt...wot should be done if i have to display data from the database in my JSP on page load.
Thank You.
20 years ago
JSP
ok..thank you..will try that out!
20 years ago
Hi,
I am using Apache axis,Tomcat 4.0,jdk1.4 and Mysql in my project.I am supposed to deploy a simple supply-chain management application.Client logs in and selects items of his choice and then the order bill is processed.I have written the code without front end .I run it in dos prompt.I want to know how to perform deployin n running of the service if i create my front end in JSP.
20 years ago