marlon tan

Ranch Hand
+ Follow
since Feb 18, 2001
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 marlon tan

Hi,

In using Java IO classes, you often wrap lower level input/output stream to a higher level one. For example,



What's the appropriate way of closing the file, do you close the file using
lower.close() or higher.close(), or both?

Thank you.
16 years ago
Hi,
Is it possible to do this without changing file.encoding property of Tomcat? I've searched the web, and the copyright character is included in the ISO-8859-1 character set.
Thank you very much
[ April 04, 2004: Message edited by: marlon tan ]
16 years ago
Hi,
There are three Tomcat environments that I'm currently working on. I have also listed some of the system properties used.
1. Local machine
- file.encoding=ISO-8859-1
- os.name=Windows XP
- os.version=5.1
2. QA server
- file.encoding=ISO-8859-1
- os.name=Linux
- os.version=2.4.9-e.35
3. Production:
- file.encoding=ISO-8859-1
- os.name=Linux
- os.version=2.4.9-e.38smp
My question is: I was trying to read from a file that contains the copyright character. When I run my web application in environments (1) and (2), the copyright character is properly read/displayed. But when I run the same application in environment (3), the question mark sign is read/displayedinstead of the copyright character.
Can someone please help?
Thank you very much.
16 years ago
Hi,
What's the use of declaring a parameter final. For example:
void myMethod(final MyObject myObj) { ... }
Thank you very much.
16 years ago

Originally posted by chi Lin:
For efficiency, you can use java.nio package for copy.
e172 of Java almanac 1.4



Hi,
I have a question regarding this method of copying file. dstFilename is very frequently read by another Java program. Is it possible that while executing dstChannel.transferFrom() method (while FileChannel is in the process of copying bytes of data), the other java program (simultaneously) reads dstFilename, will dstFilename be blank, or will the java program read half of what is supposed to be written to dstFilename?
Thank you very much
Regards,
Marlon
16 years ago

Originally posted by Mike Curwen:
Something else worth mentioning...

If you're able to upgrade to Tomcat 4.1.x or Tomcat 5.x, then you could actually use a <%@ include directive. This would benefit you in two ways:

1) You've got a much more stable, actively supported, and faster version of Tomcat
2) You've avoided the problem of the default servlet being invoked twice.

I use <%@ include on files that change periodically, and Tomcat 4.1.29 will recognize that this included file has changed, and recompile the parent file (without the parent file having to change).



Hi Again,
Our company has been using Tomcat 3.3.1a, and has no plans to upgrade to a higher version in the near future.
For now, what I did in my.jsp was to open the included HTML file using a FileReader and BufferedFileReader, read the content of the HTML, then I just output the content using out.println() statement. I know this will drastically slow down the system. I've tried using HttpURLConnection, but still, it will treat it as another request. (1) Is there any other workaround that I can do (for version 3.3.1a) that will help me solve the problem?
I believe that for version 4x and 5x, the default servlet would pertain to org.apache.catalina.servlets.DefaultServlet. (2) For Tomcat 3.3.1a, is there a corresponding default servlet which I can extend, or add to my web.xml such as:
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>... default servlet for version 3x... </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
I really appreciate your help. Thank you very much!

Regards,
Marlon
16 years ago
JSP

Originally posted by Mike Curwen:
marlon,

R K was trying to say that your directory structure as given, was "too flat". It looks like all of those folders are all hanging off of TOMCAT_HOME


Also, I think my answer in the Apache/Tomcat forum will help you.
https://coderanch.com/t/83450/Tomcat/jsp-include-page-header-html


Hi,
I think I know what you mean. My directory is not "flat" I think when I posted the message, somehow my directories were all indented to the left.
- Marlon
16 years ago
JSP

Originally posted by lali lali:
hi sir you are adding 2 jsp pages header.jsp and header.html
in these jsp there should not be any request dispatcher
RequestDispatcher rd = request.getRequestDispatcher("/a.jsp");
rd.forward(request,response);
remove this code from both the jsp you are including.
i hope it will help you
.



Hi,
My header.jsp does not contain anything but HTML table definition. If for example I ONLY have <jsp:include ..."header.html"/> in my.cbc, IllegalStateException is thrown as well.
Thank you very much.
- Marlon
16 years ago
JSP

Originally posted by R K Singh:

<hr></blockquote>
Dir structure of the above problem[/QB]



Hi,
What do you mean by the directory structure has a problem? What difference would it make if i put in my JSP files inside [mywebapp] folder, or renaming templates as something else?
Thank you very much.
Regards,
Marlon
16 years ago
JSP
Hi,
I am writing a web application that has a servlet that should handle incoming HTTP request. Using the getServletPath() method, the servlet checks if the URL is of valid format. The servlet performs some processing, and then forwards the request to a JSP file using:
getServletContext().getRequestDispatcher("/templates/my.jsp").forward(req,res)
The valid URL format should be of the form, for example, http://machine/mywebapp/2004/02/10/filename. So in effect, the getServletPath() method should return url of format /####/##/##/aFilename before the servlet can consider the request valid; otherwise request will be forwarded to error.jsp.
I am using Tomcat 3.3.1a, and JDK 1.4.2. My Tomcat has the following directory structure:
<TOMCAT_HOME>
|- webapps
|- mywebapp
|- MEAT-INF
|- templates <-- where jsp and html files reside
|- WEB-INF
|- classes
|- lib
and I have the following in my web.xml:
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.company.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

The application works fine, until I started including an HTML page using JSP action. I am not allowed to use the include directive so that whenever header.html gets updated, the right content is displayed with my.jsp. I encounter the following error message:
javax.servlet.ServletException: Cannot forward because the response has already been committed
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at templates.cbc_18._jspService(cbc_18.java:146)
... etc ...
... etc ...

my.jsp contains the following lines:
<jsp:include page="header.jsp" flush="true"/>
<jsp:include page="header.html" flush="true"/>
JSP-including another JSP file works fine, output is displayed correctly. JSP-including an HTML causes the problem. When I traced and debugged the application, I noticed that when you include an HTML, Tomcat (somehow) treats that as another request, and since I have "/" in my <url-pattern>, the request goes back to MyServlet (for the SECOND time). Making the JSP page autoFlush=false, and increasing the buffer size did not help.
When the user types in the correct URL, the request goes to the servlet, and servlet forwards the request to my.jsp, and thus committing the response; so the second time it calls forward(), IllegalStateException is thrown. Another thing that I noticed, on the second time when it enters MyServlet, calling getServletPath() returns "/templates/my.cbc", and the second call to forward() actually attempts to forward to error.jsp.

Here are my questions:
1. What's the difference between JSP-including another JSP and an HTML? Why does jsp-including an HTML file treats it as another request?
2. Is there any way that i can change web.xml? Or is there any other configuration task that I need to do? I've tried creating another context in server.xml, but all it does is to create another context of the same application.
3. If I have "/whatever/*" as my <url-pattern> in web.xml, the request should be of the format http://machine/my_web_app/whatever/2004/02/10/filename before Tomcat can dispatch the request to MyServlet. And for this case, the URL format does not follow the business requirement of the project.
Thank you very much for the help.
16 years ago
Hi,
I am writing a web application that has a servlet that should handle incoming HTTP request. Using the getServletPath() method, the servlet checks if the URL is of valid format. The servlet performs some processing, and then forwards the request to a JSP file using:
getServletContext().getRequestDispatcher("/templates/my.jsp").forward(req,res)
The valid URL format should be of the form, for example, http://machine/mywebapp/2004/02/10/filename. So in effect, the getServletPath() method should return url of format /####/##/##/aFilename before the servlet can consider the request valid; otherwise request will be forwarded to error.jsp.
I am using Tomcat 3.3.1a, and JDK 1.4.2. My Tomcat has the following directory structure:
<TOMCAT_HOME>
|- webapps
|- mywebapp
|- MEAT-INF
|- templates <-- where jsp and html files reside
|- WEB-INF
|- classes
|- lib
and I have the following in my web.xml:
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.company.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

The application works fine, until I started including an HTML page using JSP action. I am not allowed to use the include directive so that whenever header.html gets updated, the right content is displayed with my.jsp. I encounter the following error message:
javax.servlet.ServletException: Cannot forward because the response has already been committed
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at templates.cbc_18._jspService(cbc_18.java:146)
... etc ...
... etc ...

my.jsp contains the following lines:
<jsp:include page="header.jsp" flush="true"/>
<jsp:include page="header.html" flush="true"/>
JSP-including another JSP file works fine, output is displayed correctly. JSP-including an HTML causes the problem. When I traced and debugged the application, I noticed that when you include an HTML, Tomcat (somehow) treats that as another request, and since I have "/" in my <url-pattern>, the request goes back to MyServlet (for the SECOND time). Making the JSP page autoFlush=false, and increasing the buffer size did not help.
When the user types in the correct URL, the request goes to the servlet, and servlet forwards the request to my.jsp, and thus committing the response; so the second time it calls forward(), IllegalStateException is thrown. Another thing that I noticed, on the second time when it enters MyServlet, calling getServletPath() returns "/templates/my.cbc", and the second call to forward() actually attempts to forward to error.jsp.

Here are my questions:
1. What's the difference between JSP-including another JSP and an HTML? Why does jsp-including an HTML file treats it as another request?
2. Is there any way that i can change web.xml? Or is there any other configuration task that I need to do? I've tried creating another context in server.xml, but all it does is to create another context of the same application.
3. If I have "/whatever/*" as my <url-pattern> in web.xml, the request should be of the format http://machine/my_web_app/whatever/2004/02/10/filename before Tomcat can dispatch the request to MyServlet. And for this case, the URL format does not follow the business requirement of the project.
Thank you very much for the help.
16 years ago
JSP
Hi,
For the certification IBM Certified Specialist - IBM WebSphere Application Server, Advanced Single Server Edition for Multiplatforms, V4.0, what version/edition of WAS can I use to prepare for the exam?
Is the edition downloadable from IBM the right one?
Many many thanks
18 years ago
Hi. I'm about to take Test 406 this Monday. We know that Solution Developer Certification relating to WAS 3.5 Standard will be retired by IBM by Dec 31, 2001. Does this mean that if ever I pass both OOAD/UML and WAS 3.5 Standard exams before the year ends, the Solution Developer certification that I would (hopefully) be getting would no longer be recognized and credited? What if for example I plan to take up Enterprise-level certifications, say next year or maybe beyond 2002?
Thank you for the info.
18 years ago
Thank you for the info.

[This message has been edited by marlon tan (edited December 02, 2001).]
18 years ago
Thanks Kyle.
Is there any downloadable version for multi-server? Or you can only download single-server edition.
Again, thank you.
18 years ago