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



Home Answers Viewqa JSP-Servlet servlet code problem

Have Programming Question? Ask it here!
 
 
 


suresh
servlet code problem
0 Answer(s)      4 years and 5 months ago
Posted in : JSP-Servlet


This is my JSP code index.jsp

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Sync Data</title>
</head>
<body>
<h1>Sync Data</h1>
<p>Please use the following input box to upload file or enter the user id in input box directly.</p>
<form method="post" action="SyncData" enctype="multipart/form-data">
<table width="600px" cellpadding="5px" cellspacing="10px" valign="middle">
<tr><td>Upload File:</td><td><input type="file" name="userIds" size="32"></td></tr>
<tr><td>Enter UserId:</td><td><input type="text" name="singleUserId"></td></tr>
<tr><td><input type="submit" value="Sync >>" /></td></tr>
</table>
</form>

</body>

</html>

---------------------------------------------------------------------------

SyncData.java


import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

public class SyncData extends HttpServlet {

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();
List userIds = new ArrayList();
try {
if (ServletFileUpload.isMultipartContent(request)) {
ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
List fileItemsList = servletFileUpload.parseRequest(request);
Iterator iterator = fileItemsList.iterator();
while (iterator.hasNext()) {
FileItem item = (FileItem) iterator.next();




if (item.isFormField()) {

if (item.getFieldName().equals("singleUserId")) {
userIds.add(item.getString());
}
} else if (!item.isFormField()) {

StringTokenizer s = new StringTokenizer(item.getString());
while (s.hasMoreTokens()) {
String str = s.nextToken();

if (!str.equalsIgnoreCase("User") && !str.equalsIgnoreCase("ID")) {
userIds.add(str);
}
}
}
}
}
out.println(" userid >>");
} catch (Exception e) {
e.printStackTrace();
}
}
}

--------------------------------------------------------------------------

im not getting any output here!!!...,

i want to pass the texbox value and file to servlet im stuck with this error plzz help me...,
in servlet if i use request.getParameter() its showing null value and i downloaded this code from net but this also not showing the value.., and no output as well..,

thanks in advance....

Advertisement
View Answers

Related Tutorials/Questions & Answers:
code for this problem - JSP-Servlet
code for this problem   i have buttom submit .It is working with single click.Suppose if i am At the same time clicking(parallel) twise second request will be stoped until process the proces first requst and terminate
servlet code problem - JSP-Servlet
servlet code problem  This is my JSP code index.jsp Sync... here!!!..., i want to pass the texbox value and file to servlet im stuck with this error plzz help me..., in servlet if i use request.getParameter() its
Advertisements
servlet code problem - JSP-Servlet
servlet code problem  This is my JSP code index.jsp Sync Data Sync Data Please use the following input box to upload file or enter... to servlet im stuck with this error plzz help me..., thanks in advance....  
jsp code problem - JSP-Servlet
jsp code problem  Hi, I have employee details form in jsp. After... have a problem with open the next form. plz, help me. thanks,  Hi friend, Please give me detail and send me error code page. Please
JSP code problem - JSP-Servlet
JSP code problem  Hi friends, I used the following code... is the code: Display file upload form to the user... totalBytesRead = 0; //this loop converting the uploaded file into byte code while
JSP code problem - JSP-Servlet
JSP code problem  HI.. I have a DB2 stored procedure wich return a result set. I have made a report basing on this procedure using Crystal Reports. How to pass parameters to this procedure with java code in a JSP page
Jsp Code Problem - JSP-Servlet
Jsp Code Problem  I use DocType in my Jsp Page. The Links are not functioned after Applying the DocType. Could you tell me any way to activate the link. Thank You.   Hi Friend, Please send your code. Thanks
jsp code problem - JSP-Servlet
jsp code problem  i want to make the bill from the barcode. how do i convert a barcode into a decimal number
jsp code problem - JSP-Servlet
jsp code problem  hi, I am going to execute the following code which... try to execute the code it gives the following error message in the tomcat server. plz help me to run this code........ HTTP Status 500 - type Exception
javascript code problem - JSP-Servlet
javascript code problem  Thanks for sending answer.but actually what u send is not my actual requirement.first look this code. Subject...; "> in above code which is jsp and struts form bean
Java Script Code Problem - JSP-Servlet
Java Script Code Problem  how to concatenate html table values(there are 3 rows,each row contains 3 fields) into variable and display it using javascript  Hi Friend, Try the following code: document.write
Servlet problem
connectivity code it works but problem is with servlet page. My servlet code...Servlet problem  Hello, I am very shocked about this mysterious problem from last three month and now i hope rose india developers
servlet problem
servlet problem  wheni m deploying an servlet application im getting trouble context [/filename] startup failed due to previous error in tomcat 6.0.
problem in servlet program
problem in servlet program  Dear Sir, I have a problem to insert the Blob type data like as video file, audio file in the database using Servlet and html code
Java Servlet Problem - JSP-Servlet
in details for complete solution and send code the where are you problem. Thanks...Java Servlet Problem  I have a servlet class that implemets..., but in the attributeReplaced() method, i want to perform a redirect to another servlet
Servlet Problem - JSP-Servlet
Servlet Problem  Hii I am Ajay . I am makin g a project in java using servlets. I have a database in which I have stored images along with some other info(Name, address type). I want to display that info in text form along
code problem:ajax - Ajax
code problem:ajax  Hi,I am using ajax to populate a select box.for this I am writing out.write("ONE"); like that.it runs fine in firefox.bt not in IE.Can anyone help me out this... thanks
Hibernate code problem - Hibernate
Hibernate code problem  Hi, This is Birendra Pradhan.I want... in the DAO.Can it be possibe. Please send some sample code.. thanks & Regards Birendra  Hi friend, For solving the problem visit
problem with code - Ajax
problem with code  hi friends i am sending a code in that when we... to use ajax i wrote the code of jsp and the remaning code by using ajax is not wrritened by observing these below code please try the remainning ajax code its
code problem - Java Beginners
code problem  Dear sir, my problem is that I've a string value if this String value has "quit" then output should be "bye". i want to make this program using SWITCH CASE statement. how to implement String value in Switch plz
code problem - Java Beginners
code problem  Dear sir, I'm havin a problem that suppose i've got... java script j2ee j2me sql plz help me to sort out this problem. thnx   Hi Friend, Please try the following sample code to solve your problem
code problem - Java Beginners
code problem  Dear sir, My problem is that i have some string value and in some case i want to remove all the value of this string, i tried this code- Response.str.clear(); but it shows some error called "response package
hibernate code problem - Hibernate
/selectclause.shtml If you have any problem this send me detail and source code...hibernate code problem  suppose i want to fetch a row from the table through a value which i got from the jsp page. how can i do it and iterate
Hibernate code problem - Hibernate
problem please send me code. Visit for more information. http...Hibernate code problem  Hi This is Raju.I tried the first example........How can i solve this problem. Am i need to Kept any other jars in path. 
Problem with code - Java Beginners
Problem with code  Hi Deepak. Im a newbie here at your forum. I have got a simple code of mine which is having a little problem. When I compile it, i get an...,identifier expected'...error. Could you help me out? Thank you
code problem - Java Beginners
code problem  Dear sir, my problem is given below: suppose a file Carries the following lines- Name: john age: 45 Address: goa phone...; Hi friend, Code to help in solving the problem : import java.io.
code problem - Java Beginners
code problem  Dear sir, my question was actually how to find a particual line's contain, example if a file contains- hy, how r u? regrd, john... your problem in details. Which keyword search the line. Thanks
code problem - Java Beginners
of program. thnx  Hi friend, Code to help in solving the problem...code problem  Dear sir, I've some integer value in ArrayList like- 10 40 30 i want to add them and print should be like- "total value
code problem - Java Beginners
code problem  Dear sir, I have an excel file in D: drive called today.xls, i want to open it thru java program, what code would be compatible plz help me  Hi friend, Code to help in solving the problem : import
code problem - Java Beginners
code problem  Dear sir, my problem is that, i have two Combobox one.... plz tell how to code this program.   Hi Friend, You can use the following code: ComboBox var arr = new Array(); arr[0] = new
code problem - Java Beginners
; Hi friend, Code to help in solving the problem : import java.io....code problem  Dear Sir, I've to make a program where there are 10 lines of a particular file i've to display every Line's contains, example- Line1
code problem - Java Beginners
code problem  Dear sir, I've some string called "JohnSon" that has to be crypted first and then decrypted, how to crypt and decrypt data plz tell me.  Hi friend, Code to help in solving the problem : public
Application context problem code
Application context problem code   now i am posting my code here . i..."); // code to set test action environment createAction("/create", "Test", "list"); // code to execute test action String result = proxy.execute(); // code
code problem - Struts
code problem  hi friends i have 1 doubt regarding how to write the code of opensheet in action class i have done it as the action class code...(); System.out.println(conn); //Code to generate new sheet i.e login time IS NULL
problem running a servlet on tomcat.
problem running a servlet on tomcat.  i have followed the steps given... to run my servlet that is placed in the directories as it has been mentioned here... be the problem? please help me out
code problem - Java Beginners
code problem  My code is below: import java.io.*; class FileRead...()); } } } Dear sir, my problem is that suppose i enter line number: 3 if line... your code and then again try it : import java.io.*; class FileRead
problem:struts code - Struts
problem:struts code  Hi, Am using struts1.2.I wrote a form(dynavalidator form)with validation after completing the form if we press submit its call the action class,in action class i gave forward to same form,the problem is if i
logout problem.. - JSP-Servlet
done in the code i have used session object in project's servlet and jsp...logout problem..  hi... first of all thanks for ur... but their is some problem with the the logout,i m not able to logout when
Servlet Problem proceed - JSP-Servlet
Servlet Problem proceed  Thank you fro your reply. But I couldnt find any serious error.Please see this. User is the package classes/User... problem then read more details. http://www.roseindia.net/servlets
code problem - Java Beginners
code problem  i've to send a login packet( username & password..., what code should be compatible, as i heared with UDP programing there is no Guarantee of packet's delevery so send me code made of TCP, plz help me
combo box code problem
combo box code problem  in this my problem related to : when i select state MP then i wil open the its corresponding city but in database it only stores the option value no like MP at option value 10 then it will stores the 10
Hibernate code problem - Hibernate
Hibernate code problem  how to write hibernate Left outer join program
Jsp ,Servlet Problem - JSP-Servlet
to execute a servlet code on tomcat server... Thanking u... Santosh  ...Jsp ,Servlet Problem  hi, m new to jsp n Servlet. i really find ur... with oracle. it worked wonders. now i m starting jsp n servlet learning.. pls
Problem in Servlet - Servlet Interview Questions
Problem in Servlet  Sir, I have pointed everything in web.xml, path class path etc.. empController is my main servlet program and I called in form.... then some exception ..Servlet Exception: empContrller is not a servlet pgm
Code problem - Java Beginners
Code problem  Hi. I want to create a drop down button,where the value will be hard coded and on selecting an option another drop down button... and these values will come from the database. Can anyone help me with the code
Hibernate code problem - Hibernate
Hibernate code problem   Hi This is Raju I tried the first example of hibernate course material.This is to insert a record into CONTACT table.Is Hibernate code automatically creates the CONTACT table and then insert
hibernate code problem - Hibernate
hibernate code problem  String SQL_QUERY =" from Insurance...: " + insurance. getInsuranceName()); } in the above code,the hibernate... thanks shakti  Hi friend, Your code is : String SQL_QUERY =" from
code problem - Java Beginners
code problem  I want to write a program that read a string and prints... of space charaters Here is the code which I suppose is almost correct.However...; int p,i; boolean q,r,t; int count=0,count2=0,count1=0
code problem - Java Beginners
code problem  Dear sir, I want to print some line with (") this sign,like: output should come ("hello world") instead of (hello world) thnx  hi friend, If you want to print "hello world",you have to use
Code Problem - Struts
Code Problem  i want to insert multiple row values (from html table which is in jsp) into oracle database using struts.for example oracle table contains 3 fields as sub1,sub2,sub3.html table contains 10 rows of sub1,sub2,sub3
Advertisements
 

 

 

DMCA.com