Home Answers Viewqa JSP-Servlet file share to particular user

 
 


naveen kumar gupta
file share to particular user
0 Answer(s)      5 months and 17 days ago
Posted in : JSP-Servlet

hi i am doing my project in jsp-servlet.i am able to upload successfully any file to oracle database. i want to share a file to specific user , how to write code plzzz help. thank you in advance

here is my code ShowFiles

<html>
<head></head>
<body>
<form name=myname method=get action="ShowUser.jsp">
<table border="1">
<tr><td></td>
<td><b><u>File ID</u></b></td>
<td><b><u>File Description</u></b></td>
<td><b><u>Up Date</u></b></td>
<%--<td><b><u>User Description</u></b></td>--%>
</tr>

<%try
{

    int i=0;
HttpSession hs=request.getSession(true);
 if(null!=hs.getAttribute("i1"))
        {

            i=(Integer) hs.getAttribute("i1");
        }
Connection con = null;

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:naveen","naveen","naveen");
ResultSet rs = null;
Statement st=null;
st=con.createStatement();
rs = st.executeQuery("select file_id,file_desc,up_date from files where user_id='"+i+"' ");
while(rs.next()){String id=rs.getString("file_id"); %>
<tr><td><input type="checkbox" name="Check1<%=i%>" value=<%= id %>></td>
<td><%= id %></td>
<td><%= rs.getString("file_desc") %></td>
<td><%= rs.getString("up_date") %></td>
</tr><%
i++;
}
}catch(SQLException e){ out.println(e.getMessage()); } %>
</table>
<input type="submit" value="Select User">



 ShowUser


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <%@page import="java.sql.*"%>
        <title>JSP Page</title>
    </head>
    <body>
       <form name=myname method=get action="ShareFile">
<table border="1">
<tr><td></td>
<td><b><u>User ID</u></b></td>
<td><b><u>User Name</u></b></td>
<td><b><u>Password</u></b></td>
<td><b><u>User Description</u></b></td>
</tr>
<%try{

Connection con = null;

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:naveen","naveen","naveen");
ResultSet rs = null;
Statement st=null;
st=con.createStatement();
rs = st.executeQuery("select * from user_det");
int i=0; while(rs.next()){ String id=rs.getString("user_id");%>
<tr><td><input type="checkbox" name="Check2<%=i%>" value=<%= id %>></td>
<td><%= id %></td>

<td><%= rs.getString("user_nm") %></td>
<td><%= rs.getString("password") %></td>
<td><%= rs.getString("user_desc") %></td>
</tr><%
i++;
}
}catch(SQLException e){ out.println(e.getMessage()); } %>
</table>
<input type="submit">


sharefile.java


package BuisnessLogic;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet(name = "ShareFile", urlPatterns = {"/ShareFile"})
public class ShareFile extends HttpServlet {


    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        Connection con = null;
        ResultSet rs = null;
        Statement st=null;
        try {

                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                con=DriverManager.getConnection("jdbc:odbc:naveen","naveen","naveen");

                st=con.createStatement();
                Enumeration<String> paramnames = request.getParameterNames();


                while(paramnames.hasMoreElements())
                {
                        String check1 = paramnames.nextElement();
                        String check2 = paramnames.nextElement();
                        if((check1.startsWith("Check1"))&&(check2.startsWith("Check2")))
                        {   
                         st.executeUpdate("insert into share_det(file_id,user_id) values('"+request.getParameter(check1)+"','"+request.getParameter(check2)+"')");
                        }
                }
                out.println("File has sent to particular user");

            }catch(Exception e){ 
                out.println(e);
                out.println(e.getMessage()); 

        } finally {            
            out.close();
        }
    }
View Answers









Related Pages:
file share to particular user
file share to particular user  hi i am doing my project in jsp-servlet.i am able to upload successfully any file to oracle database. i want to share..."))) { st.executeUpdate("insert into share_det(file_id,user_id
reading a csv file from a particular row
reading a csv file from a particular row  how to read a csv file from a particular row and storing data to sql server by using jsp servlet
how to retreive data from database of a particular user after login
how to retreive data from database of a particular user after login  ......please help in display details of particular student after he login ...i want to display the details of only current user who logged
Count lines of a particular file
C:\vinod\Math_package>javac NumberOfLine.java C:\vinod\Math_package>java NumberOfLine Getting line number of a paritcular file example! Please enter file name with extension: AddTwoBigNumbers.shtml
writing a text into text file at particular line number
writing a text into text file at particular line number   Hi, thanks for quick response, I want to insert text at some particular line number.. after line number four my text will display in text file using java program
how to retreive data from database of a particular user after login
how to retreive data from database of a particular user after login  ... the user information.. now their is a login and registration page for newuser. after the user has filled the form he should go to the welcome page where he
how to send sms from my website to mobile of particular user.
how to send sms from my website to mobile of particular user.  i had created a website and aim of pjt is whoever the client register for site with their mobile number daily one health tip is to sent to their respective mobiles
how can i send a mail to a particular user from a many user dropdown list in jsp
how can i send a mail to a particular user from a many user dropdown list in jsp  how can i a sent a user question to a particular person from a drop down list in jsp
writing a text into text file at particular line number
writing a text into text file at particular line number   Hi, thanks for quick response, I want to insert text at some particular line number.. after line number four my text will display in text file using java program  
writing a text into text file at particular line number
writing a text into text file at particular line number   Hi, thanks for quick response, I want to insert text at some particular line number.. after line number four my text will display in text file using java program  
How to store data entered by User in JSP page in XML file
? Example: a user will enter empid,emp name ,email id on a particular page.How...   JSP store data entered by user into XML file 1)form.jsp: <html>...How to store data entered by User in JSP page in XML file  How
how to add two object in a particular file - Java Beginners
these two objects in a particular file using file handling in java....and also wants to retrieve the data of that file.............please help me out...how to add two object in a particular file  Hi frend.. I have two
User Module
User Module The user first need to make registration on the website... of that particular language. For example- if he selects java the he can only see.... User does the following task Login to the application Selects
share data iphone sdk
share data iphone sdk  How to share data in iPhone application? Actually i want the sharing feature in my iPhone application. Thanks!   You can use the emailing feature in your iPhone application to the share data
MySQL User Interface
MySQL User Interface      ..., Create function syntax , Drop function Syntax .   MySQL adding new user...;: You can add function with the help of UDF (user defined function) interface
share your answer to this question
share your answer to this question  i need to know what is the TELERIK CONTROL? what is the map suite? what is dunda chart? Also i have to know what are the websites available which give infor regarding this. Let me know how
how to find which user has modified the file
how to find which user has modified the file  how to find which user has modified the file
Spring 2.5 MVC User Registration Example
/jsp/ folder. In this file we will created user interface for enter registration...Spring MVC User Registration example       Spring 2.5 MVC User Registration Example This tutorial shows you how
User Guide, User Manuals Guides
are the functions of a particular application. While preparing a user manual we...Tips for Writing User's Manual Guide We are living in an edge of technological... the need of user guides and manuals. To let people know the various features
Manage end-user state and understand performance tradeoffs of using HTTP sessions
Manage end-user state and understand...; Manage end-user state and understand performance tradeoffs of using HTTP... to a servlet, originating from the same user at the same browser
can u plz help out how to attach file directly & send to a particular mail id
can u plz help out how to attach file directly & send to a particular mail id  i am building a project online LEAVE MANAGEMENT SYSTEM to our coll mini project so if a faculty write all details abt leave & shd send to HOD
How to Send particular error to another page in Servlet from web.xml
How to Send particular error to another page in Servlet from web.xml  How to Send particular error to another page in Servlet from web.xml   Hi you can forward particular error from web.xml file as <error-page>
to enter into a particular page only if the username,password and listbox value mtches
to enter into a particular page only if the username,password and listbox value mtches  I have created a login page in which a user could enter in to his page only if the username, password and the listbox value(user type
Selecting particular data from multiple tables at database and perfoming calculations
Selecting particular data from multiple tables at database and perfoming... users.. for eg, for the user A, let the balance at month1 is 1000... if the user A balance at month2 is 2000, i want to add those balance and display
How to enter elemets in a hashmap and check for the existence of a particular key?
How to enter elemets in a hashmap and check for the existence of a particular key?  Hi, I am trying to read a csv file and storing its contents in a hash map and checking the existence of a particular key in the hash map. Here
How to add radio button value in a table for particular field?
How to add radio button value in a table for particular field?  Hi,I...;% String username=(String)session.getAttribute("user...;% String login_user = (String)session.getAttribute("user"); Date dt
Updating user profile
. When the user clicks the particular edit button, that data will get shown...Updating user profile  how should i provide user to update his profile with edit option including entered data by user should be shown in jsp page
How to compile PHP file and provide it to user without code?
How to compile PHP file and provide it to user without code?  I have... in asp.net instead of providing code file. How can I compile the PHP file and provide it to my user in the form dll or may be with other type or extension? Please
java file handling
address which user enter. say if teh IP in teh file is IP=172.10.9.134...java file handling  Hi friends, My situation is i have file named "sample.conf" which contains more IP Adressess.Eg: the file contains "IP
calculation after if. user input
calculation after if. user input  System.out.print ("please select... addition 5 errors found: File: C:\Users\ Error: variable appleCost might not have been initialized File: C:\Users\ Error: variable carrotCost might not have been
Java Graphical user interface
Java Graphical user interface  Hi, guys. I'm christina, need help with my home work Task 1: GUI Design and Implementation The user requirements... and receives the user answer. In this screen, the registration area in the tool bar
Java file line reader
Java file line reader In this section, you will learn how to read a particular line from file. Sometimes you want to read a particular line from the file but you have to read the whole file for this process. So in order to remove
Java file exist
Java file exist  In this section, you will learn how to check the existence of the particular file. Description of code: This is a very simple task. Here we have to check whether the specified file or directory exists
Java get User Home
Java get User Home       In this section, you will study how to get the user home. We...("user.home")- This method retrieve the user's home directory
Java User Transaction - Java Beginners
Java User Transaction  Hi, I am trying to do file handling through User Transaction, I would like to know that if server crashes while writing file... Operation and file handling both in one User Transaction with atomicity
Java User Transaction. - Java Beginners
Java User Transaction.  Hi Experts, Could you please guide me for writing a java program of File Handling using user transaction, also please tell me which jars do I need. Please give me a program for above mentioned
Java File Chooser
the file system. This has made the user to select file or directory... the ability to select a particular file from the file system.  Output...Java File Chooser Java provides javax.swing.* package that is really
graphical user interface - Java Beginners
graphical user interface  how do i write a code for a jmenu bar, File with items like open, save , save as. that lead to another interface?  Hi Friend, Please visit the following link: http://www.roseindia.net
How can i select a particular item in jpopup menu through java programs
How can i select a particular item in jpopup menu through java programs  Good day Friends .... I have a doubt in jpopupmenu. That how can i sow... menu item in it. assume that the user pressing down key 3 times. I need to show
Developing User Registration Form
to the user to take the input. Here is the code of the userRegister.jsp file...\pages\user directory. In this section we have developed JSP file and Struts... Developing User Registration Form   
Servlet to authenticate user
Servlet to Authenticate User       For security everyone want to restrict the unauthenticated user... from the database then client will be entered with authenticate user and password
Making Custom (User Defined) Exceptions
Making Custom (User Defined) Exceptions   ... Making Custom (User Define Exceptions) So far you would have been known, how... appropriate and that mechanism of handling exception is called Custom or User
Java file browse
Java file browse In this section, you will learn how to browse a file and allows the user to choose a file. Description of code GUI provide File choosers... window and allows the user to choose a file.  Here we have used this class
Develop user registration form
User Registration Form in JSP       In this example we are going to work with a user registration... user registration jsp page.  In this example we will create a simple
How to store data entered in JSP page by a user in XML file & later retrieval of data using id at other page
How to store data entered in JSP page by a user in XML file & later retrieval... file.How can i store data entered by user in XML file and later retrieve data... by user to be stored in xml file.here you have entered data in JSP file
Thread Questions
areas of memory do separate threads share? Circle all that are correct. Call stack Heap Static memory They don't share any memory... share the same virtual memory; threads do not. The communication cost is lower
iPhone Icon Design
iPhone Icon Design Icon is a small graphical representation of any program, any file or any applications, which opens that particular element when... the apps, files or software which user sees first after installing on the system
Admin and User Login JSP - JSP-Servlet
Link when clicked must log out the particular user.. The admin page must also...Admin and User Login JSP  Respected Sir, I am R.Ragavendran.. i... be present along with the Emp_id and name.. But when user has individually logged
need solution to get file name from path which should give by user
need solution to get file name from path which should give by user  how do i write a program in java that i should get file path from arguments.currently this code creates the file at d:\ but i need to get this file name
File path for jar file
jar file of that application, unfortunately it is giving the error that resource not found for the template file. Also I had tried to get that path from user...File path for jar file  Hi Experts, I have created one eclipse

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.