Help writing to file in "C" using JNI
Hi,
I am trying to write the encrypted data that I read from a file. It writes the decrypted data; however, it prints extra characters at the end of file after the data. I am not sure why this is happening. Below is the code that I use to write the decrypted data to a file. I am using "C" and JNI to call Java classes in my application which is a DLL.
cipherFile = fopen ( "C:\\ciphertext.1-6", "w" );
if (cipherFile==NULL)
printf("\nCan't open cipherFile\n");
return -1;
fprintf(cipherFile, "%s", pass2EncToXUTF);
// obtain file size.
fseek (cipherFile , 0 , SEEK_END);
lSize = ftell (cipherFile);
printf("Size of cipherFile file: %d\n", lSize);
rewind (cipherFile);
fclose(cipherFile);--------------------------------------------------------------------------------
Here is the output.....
John Doe 123-45-6789 1234567890123456 01/01/1950
Jane Doe 234-56-7890 2345678901234567 02/02/1951
John Smith 345-67-8901 3456789012345678 03/03/1952
Jane Smith 456-78-9012 4567890123456789 04/04/1953
John Walker 567-89-0123 5678901234567890 05/05/1954
Jane Walker 678-90-1234 6789012345678901 06/06/1955
John Asia 789-01-2345 7890123456789012 07/07/1956
John Africa 890-12-3456 8901234567890123 08/08/1957
John Europe 901-23-4567 9012345678901234 09/09/1958
John America 012-34-5678 0123456789012345 10/10/1959
��������������
As you can see, there is some garbage printed at the end of file. Why?
Any help will be greatly appreciated. Thanks in advance.
Sorry about that.
Here's the code for jstring pass2EncToXUTF.
pass2EncToXUTF = (*env)->GetStringUTFChars(env, resultOfEncToX, 0);
if (pass2EncToXUTF == NULL) {
printf("pass2EncToXUTF is null\n");
exit(1);
printf("\nResult of pass2EncToXUTF: %s\n", pass2EncToXUTF);
Similar Messages
-
I have an ArrayList of XML strings. I am trying to write the XML strings in the arraylist to a text file. However, the only XML string that I see in the file is the first string repeated over and over. It is the only one getting to the file for some reason. I have tried the code below:
public void writeToLogFile(String logFile, String msg) {
try{
FileWriter WriteFile = new FileWriter(logFile, true);
BufferedWriter WriteBuff = new BufferedWriter(WriteFile);
WriteBuff.write(msg+"\r\n");
WriteBuff.close();
WriteFile.close();
}catch(IOException e) {
System.out.println("Error writing to file.");
// try {
// FileWriter fw = new FileWriter(logFile,true);
// PrintWriter pw = new PrintWriter(fw);
// pw.println(msg);
// pw.close();
// }catch(IOException ioExc) {
// System.out.println("error writing file");
} I tried the commented out code also. I've also tried using PrintStream. They all seem to give me the same result. My first thought was maybe I'm sending the same string to the method over and over but I'm not. If I loop through my arraylist of XML strings and do a System.out.println() instead of writing to file, I see that I am sending in different XML strings.
Here's how I'm looping through the arraylist of XML strings call "al":
for(int i=0; i<FileValues.length; i++) {
al = adapter.executeQuery(FileValues[0]);
System.out.println("Writing to output file...");
for(int x=0; x<=al.size()-1; x++) {
//System.out.println(al.get(x).toString());
test.writeToLogFile("c:/temp/a/limAdapterOutput", al.get(i).toString());
System.out.println("Finished writing to output file.");
What I'm doing is reading an arraylist (FileValues) of query parameters. For each parameter, I am querying a database based on the parameter and returning an arraylist of XML strings containing the query result. For each paramter, I'm returning about 1200 XML strings in the arraylist. Then I try to loop through the arraylist and write the XML strings to a file. However, this is when I run into my problem.
Any ideas what's going on and how I can correct the problem? Thanks.for(int i=0; i<FileValues.length; i++) {
al =
al =
al = adapter.executeQuery(FileValues[0]);
System.out.println("Writing to output
iting to output file...");
for(int x=0; x<=al.size()-1; x++) {
//System.out.println(al.get(x).toString());
test.writeToLogFile("c:/temp/a/limAdapterOutput",
ut", al.get(i).toString());
System.out.println("Finished writing
inished writing to output file.");
When you write to the log file in the inner loop, it sounds like you want to use the x loop counter, not the i counter from the outer loop. You comment out the print to System.out, which uses the x loop counter. Why don't you do the same thing in the uncommented code? Hard to follow exactly what you're doing, but maybe that will fix it. -
hi all
Newbie here........i want to write a control file for uploading data from a csv file(Excel), which has 14 colums eg:
col 1,col 2,col 3,col 4,col 5,...................col 14
and the length is not constant for the feilds...
now i need to upload only selected columns into a table.........
say.....
col2,col3,col4,col5,col8,col9 and col14........and the table is of 7 columns.......
can some one please help me in writing the control file for this requirement......
Many thanks......In that case, you should consider using EXTERNAL TABLEs.
Instead of having a control file sitting outside the database, and having to run and monitor and managed the SQL*Loader process outside the database, you can do it all from inside the database.
An EXTERNAL TABLE is basically a SQL*Loader control file. You define this once using a CREATE TABLE statement, up front. You can use the ALTER TABLE statement to specify the location and name of the CSV file.
A simply SQL SELECT allows you to load the data.
Details are in [url http://oracle.telkom.co.za:7777/oracle/oradoc102/server.102/b14200/statements_7002.htm#i2159541]Oracle® Database SQL Reference guide.
Here's the example given in the guide:
CREATE TABLE dept_external (
deptno NUMBER(6),
dname VARCHAR2(20),
loc VARCHAR2(25)
ORGANIZATION EXTERNAL
(TYPE oracle_loader
DEFAULT DIRECTORY admin
ACCESS PARAMETERS
RECORDS DELIMITED BY newline
BADFILE 'ulcase1.bad'
DISCARDFILE 'ulcase1.dis'
LOGFILE 'ulcase1.log'
SKIP 20
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
deptno INTEGER EXTERNAL(6),
dname CHAR(20),
loc CHAR(25)
LOCATION ('ulcase1.ctl')
REJECT LIMIT UNLIMITED; -
I'm trying to write a servlet that receives a file upload and
inserts the file into a CLOB in Oracle. Taking it one step at a
time. I used the O'Reilly classes for file upload to receive the
file and save it to disk. The next step of reading the file and
saving it in Oracle is where things don't seem to work.
Basically, I open a connection to Oracle. Create a new row in my
table. Select the CLOB column from the table to open the stream,
then try reading the file and writing it to the stream.
When I look at my table, I see that the row has been inserted,
but the CLOB column is null.
I'm trying to write this for eventual use in receiving
XMLdocuments into our database for processing. So if anyone has
a better way of uploading the files directly into the database
over the net, I'd appreciate it.
My code follows:
// Copyright (c) 2000 CPCC
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.driver.*;
import java.text.*;
import com.oreilly.servlet.multipart.*;
* A Class class.
* <P>
* @author Rivera, Maynard
public class UpLoad extends HttpServlet {
private File dir;
private String username = "mrr";
private String password = "auction";
private String thinConn
= "jdbc:oracle:thin:@192.1.100.6:1526:N";
private Connection cn = null;
Statement stmt;
private void OpenConnection (HttpServletResponse response)
throws SQLException, IOException {
try {
//Connect with the Thin Driver
DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver ());
cn = DriverManager.getConnection (thinConn, username,
password);
cn.setAutoCommit(true);
} catch (SQLException e) {
PrintWriter out = response.getWriter();
out.println("Error connecting to Oracle");
private void ReadFile (File Dir, String FileName, String
thedate, PrintWriter out) throws IOException {
try {
String cmd = "SELECT document FROM xmldocuments WHERE
docname = '"+FileName+"' and timestamp = to_date
('"+thedate+"', 'dd-mm-yyyy hh24:mi') for update";
out.println(cmd);
ResultSet rest = stmt.executeQuery(cmd);
rest.next();
CLOB clob = ((OracleResultSet)rest).getCLOB(1);
File theFile = new File(Dir+"\\"+FileName);
FileInputStream instream = new FileInputStream(theFile);
OutputStream outstream = clob.getAsciiOutputStream();
int size = clob.getBufferSize();
byte[] buffer = new byte[size];
int length = -1;
while ((length = instream.read(buffer)) != -1)
outstream.write(buffer, 0, length);
instream.close();
outstream.close();
} catch (SQLException e) {
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
PrintWriter out = response.getWriter();
response.setContentType("text/plain");
out.println("Upload Servlet Test");
dir = new File("c:\\myprojects");
String fileName = null;
try {
MultipartParser mp = new MultipartParser(request,
10*1024*1024);
Part part;
while ((part = mp.readNextPart()) != null) {
String name = part.getName();
if (part.isFile()) {
// it's a file part
FilePart filePart = (FilePart) part;
fileName = filePart.getFileName();
if (fileName != null) {
// the part actually contained a file
long size = filePart.writeTo(dir);
out.println("file; name=" + name + "; filename=" +
fileName +
", filePath=" + filePart.getFilePath() +
", content type=" + filePart.getContentType() +
", size=" + size);
} else {
// the field did not contain a file
out.println("file; name=" + name + "; EMPTY");
out.flush();
} catch (IOException lEx) {
// this.getServletContext().log(lEx, "error reading or
saving file");
try {
OpenConnection(response);
stmt = cn.createStatement();
SimpleDateFormat formatter = new SimpleDateFormat ("dd-MM-
yyyy HH:mm");
java.util.Date TimeStamp = new java.util.Date();
String dateString = formatter.format(TimeStamp);
String cmd = "INSERT into XMLDOCUMENTS (DOCNAME,
TIMESTAMP, DOCUMENT) VALUES ('"+fileName+"', to_date
('"+dateString+"', 'DD-MM-YYYY HH24:MI'), EMPTY_CLOB())";
ResultSet rest = stmt.executeQuery(cmd);
ReadFile(dir, fileName, dateString, out);
} catch (SQLException e) {The [url=http://otn.oracle.com/sample_code/tech/xml/xmlnews/
xnewshome.html]Dynamic News sample application shows how to read
and write CLOBs. The URL is:
http://otn.oracle.com/sample_code/tech/xml/xmlnews/xnewshome.html
Regards,
-rh -
Help:- Store Word file in database using blob
Hai all,
i want to store word document in database and reterieve from database but i don't have any idea i heared about blob but i don't know how to make it any one have source code or example form pls send me
email: [email protected]Hello,
First of all, you have got to be granted the privilege to read and write to the file system, this is a must to use BFile read access.
A global function bfilename returns a bfile taking the file path as an argument is needed to construct a blob object through dbms_lob.loadfromfile.
A very helpful example I found on orafaq follows:Create a link to the directory where the file to load in the blob is
(connect as system then grant read privilege to your user):
create or replace directory blob_dir as 'C:\Documents';
Custom the following procedure that I copied from a Thread
create or replace procedure blob_ins(p_id in number, p_filename in
varchar2) as
l_bfile bfile;
l_blob blob;
begin
insert into blob_test(p_id, empty_blob())
returning blob_file into l_blob;
l_bfile := bfilename('BLOB_DIR', p_filename);
dbms_lob.fileopen(l_bfile);
dbms_lob.loadfromfile(l_blob, l_bfile, dbms_lob.getlength(l_bfile));
dbms_lob.fileclose(l_bfile);
commit;
return;
end blob_ins;
You can use UTL_FILE package in another way, but this is much more safe;
Have Fun
Hossam Al Din -
Help: writing large data to excel using java
Hi All
I had a question writing a 6000 rows of data with 20 colums to a excel sheet. I am using Apache POI
When we are writing some data to a file we store the data in an stringbuffer and then write the data to the file all at once.
Is the same possible with excel? if so how?
And what is the best way of wring data to an EXCEL file considering the above data into consideration.
Please guide me thanks in advance.
Regards
DianaText Files and Excel formatted files treat things differently--basically no, you cannot group multiple fields into one string: Excel has the concept of cells that you need to write the data into and will act similar to fields in a DB. On the other hand, you can drop the Excel formatting and write CSV files and Excel will load them just fine. With a CSV file you can write it all to a String, StringBuffer, StringBuilder or what ever String type of object you want and write an entire line at a time.
-
Help Locating music files after transferring using Windows Migrartion Assistant
I am new to mac I just bought a new MacBook Pro Friday. I have an iPod, iPhone, and an, iPad that I need to get setup on my Mac. The way I have them setup on my Windows 7 PC is I can select wich iTunes library to open by pressing the shift key while clicking on the iTunes icon. My first question is can I set that up like that on the Mac as well? Also I used Windows Migrartion Assistant to transfer my music files from my windows 7 PC to my Mac after the transfer was finished I cannot locate the music files on the Mac anywhre. Can anyone help.
Apparently the old external drive is going bad. I turned it off and waited an hour or so and restarted it, and all my files were back. I have copied them to my PC hard drive to be safe. However, my iTunes is now totally screwed up. Although the music files are back where they were (for now), iTunes cannot find any songs except the few that were copied to the new drive when I did the consolidate. I tried the Consolidate Library again and it stops because it cannot find the files. Am I going to have to point iTunes to the location of every song, one at a time, for over 2800 songs?
-
Help with image file names when using Import Word document feature
Hello,
I am using File >> Import >> Word document into an HTML template. If the Word document contains images, the images are written to the directory specified in my Site Default Image Folder. Here is my question: As I was teaching myself the Import function, one time the images were automatically named to match the page name. So for example, if my page is named Create.html, the images would be named Create_image001.jpg, Create_image002.jpg, etc. I can't remember how I enabled this feature (or maybe I was dreaming) but if anyone knows how to control the name of the images imported from MS Word, please let me know. I've searched and Googled for hours and can't find a way to control the image file names.
Thanks in advance,
ShellieI was hoping that this would be fixed in the 10.8.2 upgrade but it has not. Anyone have any luck? Earlier today I was trying to write a paper and navigating between 10 pdfs was a nightmare without being able to hover my mouse for the titles like I used to.
-
This code is supposed to print all prime numbers between 1 and 100 to a file called PrimeNumbers. However, when I go back and check the file, all it contains is a 1. What is preventing it from printing all of the primes? Thank you.
import java.io.*;
public class Numbers
public static void main(String[] args) throws IOException
PrintWriter outputFile = new PrintWriter("PrimeNumbers.txt");
int num1, num2, num3;
for(num1=1; num1<= 100; num1++)
num3 = 0;
for(num2=1; num2<=num1; num2++)
if(((num1%num2)==0) & num2!=1 & num2!=num1)
num3=1;
if(num3==0)
System.out.println(num1 + " is a prime number\n");
outputFile.println(num1);
outputFile.close();
}Edited by: pfloyd123 on Mar 20, 2009 11:28 PM
Edited by: pfloyd123 on Mar 20, 2009 11:29 PMpfloyd123 wrote:
This code is supposed to print all prime numbers between 1 and 100 to a file called PrimeNumbers. However, when I go back and check the file, all it contains is a 1. What is preventing it from printing all of the primes? Thank you.
import java.io.*;
public class Numbers
public static void main(String[] args) throws IOException
PrintWriter outputFile = new PrintWriter("PrimeNumbers.txt");
int num1, num2, num3;
for(num1=1; num1<= 100; num1++)
num3 = 0;
for(num2=1; num2<=num1; num2++)
if(((num1%num2)==0) & num2!=1 & num2!=num1)
num3=1;
if(num3==0)
System.out.println(num1 + " is a prime number\n");
outputFile.println(num1);
outputFile.close();
}Edited by: pfloyd123 on Mar 20, 2009 11:28 PM
Edited by: pfloyd123 on Mar 20, 2009 11:29 PMI was staring at that code for five minutes trying to workout how it works. So I took a copy, and ran it... and (surpise) it works... and it's not actually too terribly slow... but I made some "performance tweaks", and now it's quit a bit faster.
The console output was the slow part. Wrapping the PrintWriter in a BufferedWriter makes no difference. Hmmm...
package forums;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.PrintWriter;
public class PrimeTester_SieveOfpfloyd123
private static final int MAX = 1000*1000;
public static void main(String[] args) throws Exception {
long start = System.nanoTime();
PrintWriter out = new PrintWriter("PrimeTester_SieveOfpfloyd123.out");
//PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("PrimeTester_SieveOfpfloyd123.out")));
int cnt = 0;
for ( int a=1; a<=MAX; a++) {
boolean isPrime = true;
int n = (int) Math.sqrt(a);
for ( int b=2; b<n; b++ ) {
if ( a%b == 0 ) {
isPrime = false;
break;
if ( isPrime) {
//System.out.print(a);
//System.out.print(++cnt%20==0 ? '\n' : ' ');
out.print(a);
out.print(++cnt%20==0 ? '\n' : ' ');
long stop = System.nanoTime();
out.close();
System.out.println("1.."+MAX+" took "+((stop-start)/1000000.0)+" millis");
}Cheers. Keith. -
I am trying to upgrade to itunes 10.7 using windows and keep getting the following error message: "Error writing to file: C:\Config.Msi\364460.rbf Verify access to this dierctory". Help!
Fixed! (win7 64 bit)! Just stop your antivirus during the upgrade/installation (I've got Kaspersky).
Good luck! -
I was trying to download iTunes on my computer, and while doing so, I got this message: Error writing to file: C:/Program Files (x86)/Common Files/Apple/Apple Application Support/Apple Versions.dll. Verify that you have access to that directory. I have downloaded iTunes numerous times and I have never had this problem. If anyone knows what's going on, I would really appreciate the help.
Well, there's definitely a mac and a Windows version. And you're at the right page. I think the problem is that someone forgot (or decided not to) to update the text at teh bottom of the page to have Mac and Windows.
Just push the button, you'll get the Mac update no problem.
Regards,
Bentley Wolfe
Senior Support Engineer, Flash/Flash Player/Digital Editions
Adobe -
Using JNI i am writing sample program i am getting the erro in jni.h
Hi,
i am writing sample programs using JNI interface while compliling the c program i am getting the error in jni.h file.
wherever the JNICALL has in jni.h i am getting the error that particular line.
can anyone help me on this regard?
Thanks
Balajibaalu999 wrote:
Hi Thanks a lot for your update
i found the correct Jni.h now i was able to compile my c program but i was unable to create .dll file in mainframe environment. can you please help me in this regard.No, because that makes no sense.
A dll runs on windows. Nothing else.
If you can't figure out how to create a dll then that is a windows question. And a windows forum works for that. -
Deploying a WAR file containing .jsp and servlets (also uses JNI)
Deploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
Server documentation on deploying such files.
This is how we went about it:
1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
Server.
C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
and
C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
(We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
service packs)
From browser, open http://yourserver:8888/
Click on Select a Server:Manage
Click on Virtual Server Class
Click on https-yourserver
Click on the Web Applications Tab
Then, click on Deploy Web Application
Enter the following -
WAR File On: Local
WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
Application URI: /jakarta
Installation Directory: c:\iPlanet\examples\jakarta-examples
By clicking on OK it deployed the application.
I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
Edit /jakarta c:/iPlanet/examples/jakarta-examples
Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
- [images]
- [jsp]
- index.html
- [servlets]
- [META-INF]
- [WEB-INF]
- [classes]
- [tlds]
- web.xml
- index.html
I restarted the server and accessed it using the following URL from my IE browser:
http://yourserver/jakarta/index.html
Then I clicked on the JSP Examples and tried some JSP examples.
b) Alternatively, you can also deploy the same example from the command-line.
Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
wdeploy deploy -u /jakarta
-i yourserver
-v https-yourserver
-d c:\iplanet\examples\jakarta-examples
C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
Restart the web server (I don't think you have to restart, but .. might as well).
2)Deploy your web-application
My Foo.war has the following structure.
You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
in your PATH)
Foo.war
- [META-INF]
- [WEB-INF]
- web.xml
- [classes]
- Bar.class
- MoServlet.class
- [lib]
- ThirdParty.jar
- [natlib]
- extlib.dll
- foo.jsp
Here is our application scenario:
foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
Now to deploy it, do the following:
(a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
JSP compile error).
<%@page language="java" import="Bar" contentType="text/html"%>
(b) Check web.xml (for Servlets)
Within web.xml, make sure you have the following mappings:
<servlet>
<servlet-name> MoLink </servlet-name>
<servlet-class> MoServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> MoLink </servlet-name>
<url-pattern> /servlet/Mo </url-pattern>
</servlet-mapping>
(c) Deploy the application
Using command line:
wdeploy deploy -u /foo
-i yourserver
-v https-yourserver
-d c:\iplanet\examples\foo-dir
Foo.war
(d) Change web-apps.xml file (for picking up ThirdParty.jar)
It is located in
C:\iPlanet\Servers\https-yourserver\config
You should see something similar to following after successful deployment.
<web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
Change it to look like following to pick up the ThirdParty.jar
<web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
<class-loader reload-interval="300"
classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
delegate="false"/>
</web-app>
(e) Change jvm12.conf file (for JNI)
It is located in
C:\iPlanet\Servers\https-yourserver\config
Add or uncomment the following lines:
#optional - just helps with instrumenting the jsp and servlet code
jvm.include.CLASSPATH=1
jvm.enableDebug=1
nes.jsp.enabledebug=1
jvm.trace=7
jvm.verboseMode=1
#required for JNI
java.compiler=NONE
jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
jvm.option=-Xrs
jvm.option=-Xnoagent
# not sure if this is needed for iPlanet web server
jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
(f) Change magnus.conf file (for JNI)
We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
in Path, it didn't work.
Change Extrapath directive:
ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
to
ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
(g) Apply changes from the Web Server Administration Console and Restart the web server.
You should be able to see the behaviour that you want from your application.
http://yourserver/foo/foo.jsp
Hope this was helpful!!!
SonuDeploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
Server documentation on deploying such files.
This is how we went about it:
1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
Server.
C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
and
C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
(We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
service packs)
From browser, open http://yourserver:8888/
Click on Select a Server:Manage
Click on Virtual Server Class
Click on https-yourserver
Click on the Web Applications Tab
Then, click on Deploy Web Application
Enter the following -
WAR File On: Local
WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
Application URI: /jakarta
Installation Directory: c:\iPlanet\examples\jakarta-examples
By clicking on OK it deployed the application.
I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
Edit /jakarta c:/iPlanet/examples/jakarta-examples
Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
- [images]
- [jsp]
- index.html
- [servlets]
- [META-INF]
- [WEB-INF]
- [classes]
- [tlds]
- web.xml
- index.html
I restarted the server and accessed it using the following URL from my IE browser:
http://yourserver/jakarta/index.html
Then I clicked on the JSP Examples and tried some JSP examples.
b) Alternatively, you can also deploy the same example from the command-line.
Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
wdeploy deploy -u /jakarta
-i yourserver
-v https-yourserver
-d c:\iplanet\examples\jakarta-examples
C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
Restart the web server (I don't think you have to restart, but .. might as well).
2)Deploy your web-application
My Foo.war has the following structure.
You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
in your PATH)
Foo.war
- [META-INF]
- [WEB-INF]
- web.xml
- [classes]
- Bar.class
- MoServlet.class
- [lib]
- ThirdParty.jar
- [natlib]
- extlib.dll
- foo.jsp
Here is our application scenario:
foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
Now to deploy it, do the following:
(a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
JSP compile error).
<%@page language="java" import="Bar" contentType="text/html"%>
(b) Check web.xml (for Servlets)
Within web.xml, make sure you have the following mappings:
<servlet>
<servlet-name> MoLink </servlet-name>
<servlet-class> MoServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> MoLink </servlet-name>
<url-pattern> /servlet/Mo </url-pattern>
</servlet-mapping>
(c) Deploy the application
Using command line:
wdeploy deploy -u /foo
-i yourserver
-v https-yourserver
-d c:\iplanet\examples\foo-dir
Foo.war
(d) Change web-apps.xml file (for picking up ThirdParty.jar)
It is located in
C:\iPlanet\Servers\https-yourserver\config
You should see something similar to following after successful deployment.
<web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
Change it to look like following to pick up the ThirdParty.jar
<web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
<class-loader reload-interval="300"
classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
delegate="false"/>
</web-app>
(e) Change jvm12.conf file (for JNI)
It is located in
C:\iPlanet\Servers\https-yourserver\config
Add or uncomment the following lines:
#optional - just helps with instrumenting the jsp and servlet code
jvm.include.CLASSPATH=1
jvm.enableDebug=1
nes.jsp.enabledebug=1
jvm.trace=7
jvm.verboseMode=1
#required for JNI
java.compiler=NONE
jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
jvm.option=-Xrs
jvm.option=-Xnoagent
# not sure if this is needed for iPlanet web server
jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
(f) Change magnus.conf file (for JNI)
We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
in Path, it didn't work.
Change Extrapath directive:
ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
to
ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
(g) Apply changes from the Web Server Administration Console and Restart the web server.
You should be able to see the behaviour that you want from your application.
http://yourserver/foo/foo.jsp
Hope this was helpful!!!
Sonu -
I need help in trying to install I Tunes,,,after multiple attempts I have now pulled all my hair out,and I am without I Tunes,,,I have tried everything ,and all the ideas that I have found in trying to seach the reason for my problem.it will download quick time,,,it gets about half way through I Tunes and I get a error message that says...........Error writing to File C /program files x86 itunes .tunes exc.verify you have access to that directory......I need the wisdom of any and all that are smarter than I about this issue.........I would appreciate any and all help ..thank you....
iOS: Unable to send or receive email
http://support.apple.com/kb/TS3899
Can’t Send Emails on iPad – Troubleshooting Steps
http://ipadhelp.com/ipad-help/ipad-cant-send-emails-troubleshooting-steps/
Setting up and troubleshooting Mail
http://www.apple.com/support/ipad/assistant/mail/
Server does not allow relaying email error, fix
http://appletoolbox.com/2012/01/server-does-not-allow-relaying-email-error-fix/
Why Does My iPad Say "Cannot Connect to Server"?
http://www.ehow.co.uk/info_8693415_ipad-say-cannot-connect-server.html
iOS: 'Mailbox Locked', account is in use on another device, or prompt to re-enter POP3 password
http://support.apple.com/kb/ts2621
iPad Mail
http://www.apple.com/support/ipad/mail/
Configuration problems with IMAP e-mail on iOS with a non-standard SSL port.
http://colinrobbins.me/2013/02/09/configuration-problems-with-imap-e-mail-on-ios -with-a-non-standard-ssl-port/
Try this first - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.)
Or this - Delete the account in Mail and then set it up again. Settings->Mail, Contacts, Calendars -> Accounts Tap on the Account, then on the red button that says Remove Account.
Cheers, Tom -
Reading/Writing .xlsx files using Webdynpro for Java
Dear All
I have a requirement to read/write excel files in .xlsx format. I am good in doing it with .xls format using jxl.jar. The jxl.jar doesn't support .xlsx format. Kindly help me in understanding how do I need to proceed on reading/writing .xlsx files using Webdynpro for Java.
Thanks and Regards
Ramamoorthy Di am using jdk 1.6.22 and IBM WebSphere
when i use poi-3.6-20091214.jar and poi-ooxml-3.6-20091214.jar to read .xlsx file. but i am getting following errors
The project was not built since its classpath is incomplete. Cannot find the class
file for java.lang.Iterable. Fix the classpath then try rebuilding this project.
This compilation unit indirectly references the missing type java.lang.Iterable
(typically some required class file is referencing a type outside the classpath)
how can i resolve it
here is the code that i have used
public class HomeAction extends DispatchAction {
public ActionForward addpage(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
String name = "C:/Documents and Settings/bharath/Desktop/Book1.xlsx";
FileInputStream fis = null;
try {
Object workbook = null;
fis = new FileInputStream(name);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sheet = (XSSFSheet) wb.getSheetAt(0);
Iterator rows = sheet.rowIterator();
int number=sheet.getLastRowNum();
System.out.println(" number of rows"+ number);
while (rows.hasNext())
XSSFRow row = ((XSSFRow) rows.next());
Iterator cells = row.cellIterator();
while(cells.hasNext())
XSSFCell cell = (XSSFCell) cells.next();
String Value=cell.getStringCellValue();
System.out.println(Value);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fis != null) {
fis.close();
return mapping.findForward("returnjsp");
Maybe you are looking for
-
Hi , I have got an error while making the proposal run the error is "Warning: Check whether a duplicate payment medium has been created" Can you please explain why this log is commng Regards Ashwin
-
Photo will not disappear from Photos app
I saved a photo from my messages into my camera roll, imported it into iPhoto, and synced it back to my iPhone. A few minutes later I deleted the photo from my iPhoto Library . . . but it refuses to disappear from my iPhone. I've turned off photo s
-
Unable to load custom trust store in cluster
Weblogic 9.2 cluster with three nodes. Each is configured to use custom trust store. The same jks is copied to every node. On node1 ssl works perfectly but on node2 and node3 certificate validation fails. Interesting is the stack that is thrown after
-
Hi, Is there any user-exit at save for transaction KL01. Here is my requirement. Where ever am employee is hired in HR ( transaction PA40; Action = Hire) i have to automatically create an Activity Type ( t.code : KL01 ). I am doing this in user-exit
-
Adobe Download Assistant freezes
adobe download assistant keeps freezing and I cannot log in. When I go to log in problem the firefox says it cannot find the programme. I have tried downloading with google chrome but that did not make any difference.