Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!

gudla Dathathreya Reddy

Greenhorn
+ Follow
since May 05, 2004
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 gudla Dathathreya Reddy

Hi there,
I am trying to deploy .ear on websphere. I am getting the following error 'the installation of application com failed.'

ADMA5058I: Application and module versions validated with versions of deployment targets.
ADMA5018I: The EJBDeploy command is running on enterprise archive (EAR) file C:\Program Files\IBM\WebSphere\AppServer\profiles\default\wstemp\0\upload\com.ear.
Starting workbench.
Creating the project.
Building: /com-server
Deploying jar com-server
Generating deployment code
Refreshing: /com-server/ejbModule.
Building: /com-server
ejbModule/com/objectmodel/server/ejb/EJSRemoteStatelesscom_objectmodel_server_ej_cb7e8f11.java(2182): Unreachable catch block for AssociationException. This exception is never thrown from the try statement body

Shutting down workbench.
Execution Halted: Compilation Errors Reported
37 Errors, 0 Warnings, 0 Informational Messages

Any body who can suggest a solution is appreciable.

Advance thanks,
Reddy
17 years ago
Hi Prasad, Paul, Jamdar,
You are still confusing Ramesh, He did'nt asked about ServletContext or ServletConfig what does blah, blah.... Might this answer will suit his question.

"The server processes(Servlet Container) of the J2EE Engine(Weblogic, WebSphere, Tomcat etc) actually execute the J2EE application(Containing Servlets). The server processes (Servlet Container) is multi-threaded, and can therefore process a large number of requests simultaneously(Handle Servlets). So the scope of the Servlet object either live or die is between the server processes .


Any comments please..
17 years ago
If the class name with public key word and the filename you are saving is not matching.....

Regards,
Reddy
17 years ago
Please check whether the Action class is mapping in struts-config.xml
17 years ago
No- but you can write your own code and call in the required JSP or controller servlets. If you require the code I definitely help you .

Regards,
Dathathreya Reddy
17 years ago
What is the error you are getting?
17 years ago
Hi Guy,
This code 100% definitely solve your problem. This is below .
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

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

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMessage;

import com.bsl.common.configuration.CommonConfiguration;
import com.bsl.sfa.Constants;


public class DownloadServlet extends HttpServlet {

private void performTask(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
try {
HttpSession session = request.getSession(false);
if (session.getAttribute(Constants.SESSION_USERID) == null) {
response.sendRedirect("/sfa/error.jsp");
} else {
String lsFileName = request.getParameter("filename");
String lsPathKey =
request.getParameter("pathkey").replace('\\', '/');

if (lsFileName != null && lsPathKey != null) {
File loDownloadFile =
new File(
CommonConfiguration.getProperty(
lsPathKey,
lsPathKey)
+ "/"
+ lsFileName);// path of the file
if (loDownloadFile.isFile()) {
InputStream is = new FileInputStream(loDownloadFile);
ServletOutputStream loOut = response.getOutputStream();
if (lsFileName.endsWith(".pdf")) {
response.setContentType("application/pdf");
} else if (lsFileName.endsWith(".doc")) {
response.setContentType("application/msword");
} else if (lsFileName.endsWith(".xls")) {
response.setContentType("application/vnd.ms-excel");
} else {
response.setContentType(
"application/download; charset=UTF-8");
}
response.setHeader(
"Content-Disposition",
"attachment;filename=" + lsFileName);
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = is.read(buffer, 0, 8192)) != -1) {
loOut.write(buffer, 0, bytesRead);
}
loOut.flush();
is.close();
loOut.close();
} else {
throw new FileNotFoundException("File not found");
}
} else {
throw new FileNotFoundException("File not found");
}
}
} catch (Throwable t) {
ActionErrors errors = new ActionErrors();
if (t instanceof FileNotFoundException) {
ActionMessage error =
new ActionMessage("global.error.filenotfound");
errors.add(ActionErrors.GLOBAL_ERROR, error);
request.setAttribute("org.apache.struts.action.ERROR", errors);
} else {
ActionMessage error = new ActionMessage("global.error.general");
errors.add(ActionErrors.GLOBAL_ERROR, error);
request.setAttribute("org.apache.struts.action.ERROR", errors);
}
this.getServletContext().getRequestDispatcher(
"/error.jsp").forward(
request,
response);
}
}
/* (non-Javadoc)
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
performTask(req, res);
}

/* (non-Javadoc)
* @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
performTask(req, res);
}

}

Regards,
Dathathreya Reddy,
Cramer System Europe Limited,
dathathreya.gudla@cramer.com
17 years ago
Of course from JSP you an used the <forward ....>(see document) and from servlet to jsp you can use forward(ServletRequest res, ServletResponse) method of RequestDispatcher interface. I could'nt understand handler stuff . Can you send me the details stuff of Handler .
17 years ago
Beans are used especially when you want to hold some data and this data can be transmitted from business layer to presentation or database layer to business layer etc. Most cases to hold data use bean. At the same time beans are some type of Java classes with some convention rule such as it should have a constructor with zero arguments, data member and setter, getter methods.
When you come accross to use a java class it can be use for any activities apart from holding data.
17 years ago
Can any body help to sort out this problem, When I am trying to transform an XML to another XML using XSLT I am getting the following exception oracle.xml.parser.v2.XMLParserException: Whitespace Exception. My piece of codes are as below .

XSLT:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:quipmentGenerator="http://www.oracle.com/XSL/Transform/java/EquipmentGenerator xmlns:TypeGenerator="http://www.oracle.com/XSL/Transform/java/TypeGenerator xmlns:ShelfGenerator="http://www.oracle.com/XSL/Transform/java/ShelfGenerator">
....
</xsl:stylesheet>

JAVA :
import java.io.*;
import java.net.URL;
import java.net.MalformedURLException;
import oracle.xml.parser.v2.*;

public class Transformer
{
public static void main(String args[]) throws Exception{
String fileName = "abc.xsl", XMLStr = "C:\\dev\\task2\\abc.xml";
XSLProcessor processor = new XSLProcessor();
// you can also use a standard HTTP URL instead of
// the file protocol shown below
// URL xslURL = new URL(fileName);

// instantiate a stylesheet
InputStream xslInput = new FileInputStream(fileName);
XSLStylesheet stylesheet = processor.newXSLStylesheet(xslInput);
DOMParser parser = new DOMParser();
URL xslURL = new URL("file://" + XMLStr);
parser.setPreserveWhitespace(true);
parser.parse(xslURL);
// Preparing the XML document
XMLDocument xml = parser.getDocument();
XMLDocumentFragment result;
result = processor.processXSL(stylesheet, xml);
// create an output document to hold the result
XMLDocument out = new XMLDocument();
// create a dummy document element for the
// output document
out.appendChild(result);
ByteArrayOutputStream outStream = new ByteArrayOutputStream( );
out.print(outStream);
String transformedXML = outStream.toString();
System.out.println(transformedXML);
}
}
I am looking for some examples of using XSLT style sheets that makes
a call to an external function to perform part of its transformation.

This should be based on OracleXSL engine.

I am having a piece of code snippnet :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:java="http://www.oracle.com/XSL/Transform/java" xmlns:udme="EquipmentGenerator" xmlns:udmt="TypeGenerator" xmlns:udms="ShelfGenerator" > ....</xsl:stylesheet>

Please tell me whether the about sytax is correct or not and even some examples .
hi guy,
You r using a deprecated methods of SAX API. You can compile your file as like this 'javac FileName -deprecation' , Now it will compile. Even u have to use the JDK version 1.3 and above and check whether class path is set properly .

Regards,
Dathathreya Reddy
Hi Dinaker,
You mean to say that there are 2 input text boxes which is inputed when I click a button then the input data should be converted into an XML file . If this is ur question then bring the input valuesand name using getRequestParameterNames() and Write this to a File .
Hi friends,
I am getting a problem in my application. I will state the complete problem in detail. I have to transfer 3 files from one NT machine to unix machine some where kept in net work, I used an ftp in 'Process p = getRunTime().exec("ftp -i -s:ftp.txt")'. In ftp.txt file I have given the necessary things for ftp to unix machine. The files are transfering into the unix box. When I to the process for the 2nd time I have to check whether the file are exists in the unix box, then only transfer the files. Now, again I am doing ftp bring the files from the unix box to NT machines using 'Process p = getRunTime().exec("ftp -i -s:ftp1.txt")' where ftp1 contains all the necessary things for ftp to unix machine . Now I am checking for the files available in the NT machine using boolean=(new File(filename)).exists(), Fine out of 3 files, 2 file shows the return type as 'true' and one file is showing 'false', even the same happens if I delete the 3 files after checking, out of 3 files, 2 file shows the return type as 'true' and one file is showing 'false'. I went to the folder where I am bring files from and removing the files manually, one file is showing share violation, one process is using the file . I am unable to resolve this problem, will this code what I write is acceptable if not suggest any other code. I have sending all the snippets of the programs. I am doing this in the development environment like this. My production environment is totally both are unix machines.

1. ftp to transfer files.(tranfer.txt)called in java code down

open 172.16.30.6
informix
informix
bin
has
cd /tmp
put d:/dathu/CSV/bssfa932.txt
put d:/dathu/CSV/bssfa933.txt
put d:/dathu/CSV/bssfa936.txt
bye

2. ftp to get the files(get.txt)used in java code down

open 172.16.30.6
informix
informix
bin
has
cd /tmp
lcd d:/dathu/hold
get bssfa932.txt
get bssfa933.txt
get bssfa936.txt
bye

3. java code snippet to getfiles
Process p = Runtime.getRuntime().exec("ftp -i -s:get.txt");

4. java code to check the files exist

boolean filestatus=moCreatFlatFilerobj.isFileExists();

public boolean isFileExists(){
boolean isfileexisting=false;
boolean blnordhead = (new File(file1 with path)).exists();
boolean blnordlines = (new File(file2 with path)).exists();
boolean blnaccount = (new File(file3 with path)).exists();
if(blnordhead && blnordlines && blnaccount){
isfileexisting=true;
return isfileexisting;
}

5. java code to delete files

public void deleteFiles(){
boolean header= (new File(file1 with path)).delete();
boolean line =(new File(file2 with path)).delete();
boolean account=(new File(file3 with path)).delete();
}

6. java code to tranfer files.
p = Runtime.getRuntime().exec("ftp -i -s:transfer.txt");

Please help me...
My email dathathreyareddy@yahoo.co.in