Deepak Chawla

Ranch Hand
+ Follow
since Nov 19, 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 Deepak Chawla

I am using IE 5.5
This is my HTML output

[edited: Reformatted Code So easier to read]
[ December 19, 2003: Message edited by: Eric Pascarello ]
I have JSP form Page and i want to reset values in form

[edit:reformated code so easier to read]

When i try to click on Reset , it only reset value fromtextarea which is labeled as "Notes/issues/open items", not from other fields. I don't know why. can anyone please help

[ December 19, 2003: Message edited by: Eric Pascarello ]
Can anyone please help me on this issue ??
I tried what you guys advised to me and it compiles fine, but when i
try to run the page i am getting this error:
10.4.5 404 Not Found
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.
If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.

These are the changes i did:
package DBAccess;
import DBAccess.*;
import java.io.* ;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import java.text.*;
public class ProjectDatabase
{
java.util.Date today = new java.util.Date();
SimpleDateFormat myFormat = new SimpleDateFormat("yyMMddHHmmssZ");
String Id = myFormat.format(today);
}
This is my sql query
stmt.executeUpdate ("Insert into sandbox.event(EVENTID,OTHERATTENDEE,NOTES,APPROVE)values('" + Id + "','" + Attendees + "','" + Notes + "','" + Check + "')");
Can anyone help what i did wrong here. My other pages are running fine.
Guys it is working now, but i have 1 problem, i want that date should be into numbers. Right now it is storing like this in database:
Thu Dec 18 11:36:07 EST 2003
I want that it should break it down into numbers and also include time with seconds.
Can anyone tell me how to do that??
can anyone tell me how to solve this problem.
Sorry Pardeep i got confused before. Here's what i want to do, i want that
date should be converted into string format, so that i can use it as primary key.
sql and util has tostring() method but different functionality.
sql toString() converts into mm-dd-yy.
util toString() converts into string.
so i have to use util package.
My eventid in database is primary key with varchar2 datatype.
this is what i am doing now
package DBAccess;
import DBAccess.*;
import java.io.* ;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;

java.util.Date today = new java.util.Date();
String Id = today.toString();
My insert query is like this :
stmt.executeUpdate ("Insert into sandbox.event(EVENTID,OTHERATTENDEE,NOTES,APPROVE)values('" + Id + "','" + Attendees + "','" + Notes + "','" + Check + "')");
I am getting these errors now:
:\itads\source\DBAccess\ProjectDatabase.java:11: 'class' or 'interface' expected
[javac] java.util.Date today = new java.util.Date();
[javac] ^
[javac] H:\itads\source\DBAccess\ProjectDatabase.java:13: 'class' or 'interface' expected
[javac] String Id = today.toString();
[javac] ^
[javac] H:\itads\source\DBAccess\ProjectDatabase.java:300: cannot resolve symbol
[javac] symbol : variable Id
[javac] location: class DBAccess.ProjectDatabase
[javac] stmt.executeUpdate ("Insert into sandbox.event(EVENTID,OTHERATTENDEE,NOTES,APPROVE)values('" + Id + "','" + Attendees + "','" + Notes + "','" + Check + "')");
[javac]
I can't take 1 package out boz i am using some classes which are in util package, i tried to do this with my import statement
package DBAccess;
import DBAccess.*;
import java.io.* ;
import java.util.*;
import java.sql.*;
import java.sql.Date;
import javax.sql.*;
import javax.naming.*;
Same errors.
plz help
I am trying to insert date in database, I have primary key EVENTID with data type Date:
This part of my class where i am performing this function
package DBAccess;
import DBAccess.*;
import java.io.* ;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
Date today = new Date();
This is my function
public void createEvent(String Attendees,String Notes, String Check)
{
try
{
Context context = new InitialContext();
DataSource ds = (DataSource) context.lookup( "itarchutil-datasource" );
Connection con = ds.getConnection();
Statement stmt = con.createStatement();
stmt.executeUpdate ("Insert into sandbox.event(EVENTID,OTHERATTENDEE,NOTES,APPROVE)values('" + today + "','" + Attendees + "','" + Notes + "','" + Check + "')");
stmt.close();
con.close();
}
catch (Exception e)
{
System.out.println("Error:" + e);

}

}
I am getting the following errors:
H:\itads\source\DBAccess\ProjectDatabase.java:11: 'class' or 'interface' expected
[javac] today = new Date();
H:\itads\source\DBAccess\ProjectDatabase.java:298: cannot resolve symbol
[javac] symbol : variable today
[javac] location: class DBAccess.ProjectDatabase
[javac] stmt.executeUpdate ("Insert into sandbox.event(EVENTID,OTHERATTENDEE,NOTES,APPROVE)values('" + today + "','" + Attendees + "','" + Notes + "','" + Check + "')");

Can any one help??
Thanks
^
Can anyone give me sugesstion on my problem which i wrote below.
Thanks
16 years ago
Ok i am calling doGet method from doPost, but now inserting in database i have to put the code in doPost method, so then now where should i place my code which is in doPost method which get the values in the form and call few methods. how to sepearte them.
I want that servelt should 2 things , saves the files in the directory and insert other vlaues in database, is there any other way to do this which i am trying to do.
16 years ago
String Attendees = mySmartUpload.getRequest().getParameter("participants");
String NoteHistory = mySmartUpload.getRequest().getParameter("notehistory");
I can't try this code, because this part was used for uploading files in the directory.
I am using this request.getParameter(String)in my other servlets and it is working fine. I have 2 textareas with name "partcipants" and "notehistory" in my JSP form and those values i am trying to pass in servelet and to check if the values passed, it prints NULL on console.
I have pasted my servlet and form code above.
Please help.
16 years ago
The code which told is already working fine, I have problem here
String Attendees = request.getParameter("participants");
String NoteHistory = request.getParameter("notehistory");
System.out.println(Attendees); /* this print null on console*/
System.out.println(NoteHistory);/* this prints null on conso
This code is in my servlet and when i try to print its value, it prints null.
16 years ago
I Have a JSP form which cals servlet, that servelt uploads file in directory and insert other values of form in database. My uploading of files is working perfect, in that servlet now i am trying to call values of form through getParameter to insert in database. But it oesn't get the values and prints NULL.
please help
This is my Form
<form name= "projectinfo" method ="Post" action="saveFiles.servlet" title="theEventForm" ENCtype="multipart/form-data">
<input type="HIDDEN" name="Project" value="<%=projectname%>" size="100"/>
<input type="HIDDEN" name="Event_type" value="<%=eventtype%>" size="100"/>
<table border="0" cellspacing="4" cellpadding="0">


<tr>
<td align="right" width='200'>Event Type: </td>
<td align="left">
<select name='eventtype' onchange='eventtypeselect(this)'>
<option value=''></option>
<option value=''>TechPreScreen</option>
<option value=''>Passport1</span></option>
<option value=''>Passport2</option>
<option value=''>Passport3</option>
<option value=''>Passport4</option>
<option value=''>DesignReview</span></option>

</select>
</td>
</tr>

<%
// Declare some variables to use across multiple java blocks in this form
String attendees = "" ;
String notehistory ="";
boolean goteventtype = false ;
ProjectEvent pe = null;
String [] filenames = new String[0];


if ( eventtype != null && projectname !=null)
{
pe = db.getEventType(eventtype,projectname);
if (pe != null)
{
filenames = pe.getFileNames();
attendees = pe.getParticipants();
notehistory =pe.getNoteHistory();
goteventtype = true;
}

}


%>
</td>

</tr>
<tr>
<td align="right">Key contacts or participants:</td>
<td align ="left"><textarea name="participants" cols='45' rows='1'><% out.write (attendees);%></textarea></td>
</tr>
<tr>

<td align="right">IT Architecture Approved ?: </td>
<td align="left" >
<input type="checkbox" name='approved' checked="checked">
</td>



</tr>
<tr>
<td align="right">Notes/Issues/Open items: </td>
<td align="left"> <textarea name="notes" cols='50' rows='1'></textarea>


</td>

</tr>
<tr>
<td align="right">Notes History: </td>
<td align="left"><textarea name="notehistory" cols='50' rows='2' disabled='true'><% out.write(notehistory); %></textarea></td>



</tr>


<tr>
<table>

<td align="right">Attachments:</td>
<td align="left">

<table>
<tr><td>
<%
int filesdisplay = filenames.length;
for(int i =0;i<filesdisplay;i++)
{
out.write("<a href='/itads/docs/" + projectname + "/" + eventtype +"/"+filenames[i]+"'>" + filenames[i] +"</a><br>");
}



%>

</td></tr>

</table>

<table id="theAttachmentTable" border="0" cellspacing="0" cellpadding="0">
<tr><td><input type="FILE" name="FILE1" size="80" onchange="javascript:addNewAttachmentField();"/></td></tr>
</table>
</td></tr>
<td></td>
</table>

<tr>
<td align="center">
<input type="button" name="refresh" value='Refresh'>
</td>
<td align="center">
<td align="center">
<input type="submit" name="savedoc" value="Save ">
</td>


</tr>
</table>
</form>
</td>
</tr>
</table>

</body>
</html>
This is my Servlet
package servlet;
import DBAccess.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.servlet.*;
import javax.naming.*;
import javax.servlet.http.*;
import com.jspsmart.upload.*;
public class saveFiles extends HttpServlet {
/*boolean p = false;*/
char squote ='\'';
char dquote ='\'';

public void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
try {
ServletContext context = getServletContext();
ServletConfig config = getServletConfig();
String sessionId = request.getSession().getId();
java.io.File tempdir = (java.io.File) context.getAttribute( "javax.servlet.context.tempdir" );
out.write( "<html>" );
out.write( "<head>" );
out.write( "<title>Upload Files Servlet [" + request.getServerName() + "]</title>" );
out.write( "</head>" );
out.write( "<body>" );
ResourceBundle rb = ResourceBundle.getBundle("Project");
String rootdir_name = rb.getString("projectDocRootDirectory");
if ( rootdir_name.equals("TEMP") )
{
rootdir_name = tempdir.getPath() + "\\upload";
}
RequestDispatcher dispatcher = context.getRequestDispatcher( "/header.jsp" );;
dispatcher.include(request, response);
out.write( "<h1>Upload Files!</h1>" );
int count=0;
com.jspsmart.upload.SmartUpload mySmartUpload = new com.jspsmart.upload.SmartUpload();
mySmartUpload.initialize(config,request,response);
//mySmartUpload.setTotalMaxFileSize(10000000);
//mySmartUpload.setMaxFileSize(10000000);
mySmartUpload.upload();
String project_name = mySmartUpload.getRequest().getParameter("Project");
String eventtype_name = mySmartUpload.getRequest().getParameter("Event_type");
String subdir_name=project_name +"/"+ eventtype_name;
if ( subdir_name == null )
{
subdir_name = ".";
}
String dir_name = rootdir_name + "/" + subdir_name;
System.out.println(dir_name);
java.io.File dir = (java.io.File) new java.io.File( dir_name );
if ( !dir.exists() )
{
dir.mkdirs();
}
count = mySmartUpload.save( dir.getPath() );
out.println( "<p>" + count + " file(s) uploaded to " + dir.getPath() + ".</p>" );

out.println( "<ul>" );
com.jspsmart.upload.Files files = mySmartUpload.getFiles();
out.println( "<ul>" );
for ( int i=0; i<count; i++ )
{
com.jspsmart.upload.File f = files.getFile(i);
out.println( "<li>" + f.getFileName() + " [" + f.getSize() + " bytes]</li>" );
}
out.println( "</ul>" );
dispatcher = context.getRequestDispatcher( "/footer.jsp" );
dispatcher.include(request, response);
out.write( "</body>" );
out.write( "</html>" );
}
catch (Exception e) {
log(e.getMessage());
e.printStackTrace();
}
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String Attendees = request.getParameter("participants");
String NoteHistory = request.getParameter("notehistory");
System.out.println(Attendees); /* this print null on console*/
System.out.println(NoteHistory);/* this prints null on console*/
ProjectDatabase db = new ProjectDatabase();
String ANames =db.changeQuote(Attendees,squote,dquote);
String Notes =db.changeQuote(NoteHistory,squote,dquote);
db.createEvent(ANames,Notes);
doGet(request, response);
}
}
16 years ago
Hi Guys
I am trying to Insatll JSP Smart UPLOAD on my BEA WEBLOGIC Web Server, does anyone know about the documenation of installing on BEA or anyone knows how to do that.
plz help
16 years ago
JSP