[Tomcat bug?] Calling response.sendError(404) from JSP
Calling "response.sendError(404);" from JSP context causes Tomcat to mangle all non-latin characters.
Any ideas why?
How to recreate bug:
http://www.kitoy.ru/int/bug1.zip
There are 3 files in bug1.zip.
index..jsp:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page pageEncoding="utf-8"%>
<%@page contentType="text/html; charset=utf-8"%>
<%
response.sendError(404);
%>
<html>
</html>404.jsp:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page pageEncoding="utf-8"%>
<%@page contentType="text/html; charset=utf-8"%>
<html>
<h1>Hello in Russian: Привет!</h1>
</html>and WEB-INF\web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>bug1</display-name>
<description>bug1</description>
<distributable/>
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
</web-app>Calling of index.jsp should cause 404 error with custom error page. The error page is utf-8 encoded and contains russian characters. That's by design.
In fact, Tomcat shows ?????? instead Russian variant of "Hello".
Tomcat/5.5.17 or Tomcat/5.0.28.- it does not matter.
Is it Tomcat bug or I should not call response.sendError(404) from JSP?
it's not a tomcat bug, it's rather a problem with
your code.
change index.jsp like the following then test
it !
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page pageEncoding="utf-8"%>
<%@page contentType="text/html; charset=utf-8"%>
<%
esponse.sendRedirect("blablablablablabla.html");
%>
<html>
</html>
Thanks for the insight. But the issue here is with the response.sendError() method.
Similar Messages
-
Calling (VB)activex object from JSP
Hi,
I am trying to call a ActiveX object from JSP using the ActiveXObject method in javascript. I have a dll filed named LPMSFunctions.dll which is registered and is being passed as an argument to the ActiveXObject method. Below is the code i am trying to execute..
<html>
<head>
<title>Script Example</title>
</head>
<body>
<br><br>
<P align="center">
<form action="" method="post">
<script language="JavaScript">
function comEventOccured()
try{
var myobject;
myobject = new ActiveXObject("LPMSFunctions72.LPFunctions72");
alert("Inside LPMSFunction72");
alert(myobject.GetDocPath());
catch(e)
alert("Error");
</script>
</form>
</body>
</html>When i write the above code and save it as an html file it works fine..the activex object is created and the methods are called , but when i copy the same code to a file and save it as jsp file under webapps folder under tomcat it doesnt work and reports a javascript error with the error being:
Automation server cant create the object at line :
var SSOObj = new ActiveXObject("LPMSFunctions72.LPFunctions72");
Please suggest how can I solve the problem. Your help would be sincerely appreciated.
Thanks
shravanYou want to use the Variant to Data node, wiring in an ActiveX constant configured to the interface type you want.
Brian Tyler
http://detritus.blogs.com/lycangeek -
Hi guys,
I am developing an online ticket booking system.
i have come toa point where i need to call a perl script from JSP.
please let me know how to do it.
Basically, i need to call a function in perl script from JSP in order to encrypt my information.
Any help is appreciated.
Thanks in advance.
Chintan ShahI haven't done this myself, but it seems like it is possible in Tomcat.
You can configure Tomcat to handle .cgi calls (it does this via a CGI servlet)
http://www.ftponline.com/javapro/2003_03/online/perl_teden_03_18_03/
http://tomcat.apache.org/tomcat-5.0-doc/cgi-howto.html
Once this is set up, theoretically you should be able to then use requestdispatcher and forward/include a cgi script to invoke the perl.
I don't know if you are using Tomcat or not though... :-) -
How to call java script function from JSP ?
how to call java script function from JSP ?
i have function created by java script lets say x and i want to call this function from jsp scriplet tag which is at the same page ..thanks
-
Calling custom OAF page from JSP page in Oracle apps
Hi,
I am working on a requirement to call a Custom OAF page from a JSP page in Oracle apps 11.5.10.
I have registered the OAF page and defined a function for it. When we call this OAF page from JSP (without parameter), the page opens up
URL: http://APPSURL:8020/OA_HTML/RF.jsp?function_id=27221&resp_id=50312&resp_appl_id=515&security_group_id=0&lang_code=US
but as soon as I am trying to pass a parameter sr_id in the URL:
http://APPSURL:8020/OA_HTML/RF.jsp?function_id=27221&resp_id=50312&resp_appl_id=515&security_group_id=0&lang_code=US&sr_id=106
we are getting following error:
You are trying to access a page that is no longer active.
- The referring page may have come from a previous session. Please select Home to proceed.
Please let me know if someone has faced the same problem...
Thanks!!!Hi,
Before calling a OAF page..from external JSP page...u need to set certain mandatory parameter like transaction Id and context.
Regards,
Gyan -
Calling abap rfc FM from jsp programming
hi friends,
I am having a requirement to call abap function module from jsp page. can any one help me please?
thanks
Medoyi CHi Medoyi,
Please follow the below steps
1. Are you using NWDS or any other IDE? Create your Web Project.
2. In any of the case download JCO3.0 jar files and add to these librarries to you IDE.
3. Create a connection class in write a code here and you should have host, port and userid/password of the ECC system from where you are calling your RFC.
4. After making a connection then write a code to pass import parameters and execute.
5. After execution of RFC you will get export parameter, table or structure.
6. Display this data now as a respose.
Please reply back if any more information is required.
Thanks,
Hamendra -
Calling my Java class from JSP page
Hello, I am trying to call my Java class from my JSP page passing parameters to it and getting back a collection of result sets. Can someone tell me what I might be doing wrong:
JSP code to call Java class:
<%
String strEssUser = "test";
String strProcessingMonth = "JUL";
String strProcessingYear = "2002";
strQueryList=new ListReturn(strEssUser.toString(), strProcessingMonth.toString(), strProcessingYear.toString());
%>
I get this error when I try to run this JSP page using tomcat:
C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\em\jsp\Test_0005fSummarySBU_0005fscreen$jsp.java:77: Class org.apache.jsp.ListReturn not found.
strQueryList=new ListReturn(strEssUser.toString(), strProcessingMonth.toString(), strProcessingYear.toString());
I'm not sure if this problem is the way I am calling the Java class, or if I have a problem in the Java code itself. Can anyone help?Ok, I get a very strange error now:
org.apache.jasper.JasperException: Unable to compile class for JSPerror: An error has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
What is this??? Anyone? -
Call pl/sql API from jsp portlets
HI ALL!
I need to ask from java developers for portal application,How can i call pl/sql API from my jsp portlets,What enhancements in code should i have to follow in addition to use JDBC,I read in FAQ abt portal some thing abt pl/sql wrapper but that was for complex scenarios ,what if my requirement is to call only API functions for contentareas,items,previleges etc.I really need help.
thx
AlizehHi
thanks for ur reply but where were u a month ago,i really started to think that my question was enough stupid not to be answered.At present i have done with jdbc and pl/sql calls ,current concern is for sessions as i see that session id remains same when one user logs out and another logs in(if browser is not closed), same sessionid persists in my java portlet for both users.Is this an expected behaviour?? but yes new session id appears if browser is closed.
.session clear for both application and sso after logout is checked
.broser is set to check for new version each visit for the page
portal version is 3.0.9.8.0 ,we r planning patch to 3.0.9.8.3 soon
once again thx
Alizeh -
How to call Generic Page flow from jsp
Hi All,
I have some links in my home page(jsp file).Based on user's selection, i need to show another JSP page using pageflow(JPF).
thanks in advance
vandanai have function created by java script lets say x and i want to call this function from jsp scriplet tag which is at the same page ..thanks
-
How to call java class file from jsp
hi
we need to call java classes (which are written separately in .java file )from jsp file. we need it for our project if anyone knows about please reply us.
bye
siva sankariyou can call the methods in a lot of ways. you could use scriptlets with the
<%@ page import="package.class"%> and then inside instantiate an object
<%
MyClass mc = new MyClass(parameters if any);
mc.theMethodYouWantToCall();
%>or as Madathil has stated,
or use the JSP tags
<jsp:useBean id="anyname" class="classname"/>and then use the getProperty tag
or even Custom Tags -
How to call an ejb method from jsp?
Hi, everyone!
Inside my JSP, I4m using scripts in order to show and receive information, that is, a form.But I don4t Know if I can use the same variables from the script in order to call the 'set' methods from my EJB.
Could anyone show me an example?
Thanks in advance,
SilviaInitialContext ctx = new InitialContext();
GeneralEditor editor = (GeneralEditor) ctx
.lookup("GeneralEditorBean/remote");
GeneralService service = (GeneralService) ctx
.lookup("GeneralServiceBean/remote");
LanMu lm = new LanMu();
lm.setName("shdfkhsad");
editor.add(lm); -
How to call custom Login Module from JSP
Hi,
I am stuck with the following issue:
1) Exactly as presented in help.sap.com (http://help.sap.com/saphelp_nw04/helpdata/en/3f/1be040e136742ae10000000a155106/content.htm) I created custom login module and deployed it as a library on J2EE server. When I configured it to be used for my applications in the Security provider but I am getting "No user name provided" exception everytime when my applications use this custom login module.
2) I realized that I would need to call my custom module somewhere within my application (simple JSP) using LoginContext class and then use MyLoginContext.login() spec to initiate login process. But I am not able to pass CallbackHandler parameters from JSP application to my custom login module.
So I have the following questions:
1. Can I pass parameters using LoginContext and CallbackHandler from JSP to my custom login module (created as exact copy of HELP.SAP.COM example) or this module cannot be used this way.
2. How to pass CallbackHandler correctly to my custom login module from JSP. When I am trying to use CallbackHandler, I am getting "Abstract Class cannot be called" error.
I'd appreciate any little help on this matter.
Thanks and regards,
MikeYou have two alternatives to do this:
You can declare your JSP as a protected resource with the use of the deployment descriptors of the application (web.xml) and add the custom login module in the authentication stack of the application. This way, you will use container-based authentication, i.e. the Web Container will enforce the authentication and it will call the custom login module before it dispatches to the JSP. I recommend you this approach because it requires less coding and it makes the whole thing a matter of configuration. The configuration can be later on enhanced or changed runtime without the need to re-build and re-deploy the application. If you choose this approach you can go to the documentation of the server for help on how to modify the login module stack of the application.
You can also use programmatic authentication by using JAAS API. To do this you need to create a custom security policy configuration with login module stack containing the custom login module, and then use the standard JAAS mechanism - new LoginContext(<configuration>, <callback-handler>).login(). This approach requires that you write your own callback handler and handle any LoginException.
Let us know which approach you prefer and whether you have difficulties implementing it! -
Call Crystal Report 8 from JSP?
Can anyone help me on how to call Crystal Report 8 (*.rpt) from JSP page? The JSP is deploy into J2EE application.
Thanks
KennyThere is not any direct support, but you can use INet Crystal Clear API. It comes with an Applet client, and you can use that applet client from jsp to display crystal reports.
-
Call to BPEL Process from JSP - Not working!
Hi All,
I'm trying to execute the sample JSP page provided in the BPEL Guide, which calls the BPEL "CreditRatingService" service.
The JSP Page compiled normally, but it does not invoke the BPEL Process. The JSP Page is just waiting.. the browser is loading the page for ever..which means it is not able to call the BPEL process. If i comment the below code
NormalizedMessage res = deliveryService.request("CreditRatingService", "process", nm);
then the page is displaying..
Thanks for any help
Regards
ChandraHi Afonso,
I looked at the files under the below locations..
C:\product\10.1.3.1\OracleAS_1\j2ee\home\log\home_default_group_1
C:\product\10.1.3.1\OracleAS_1\bpel\system\logs
C:\product\10.1.3.1\OracleAS_1\bpel\domains\default\logs
I found the below error mesage
<ERROR> <collaxa> <ProcessJob::execute> Timed out reading http:.........
from C:\product\10.1.3.1\OracleAS_1\bpel\system\logs\orabpel.txt log file.
But this log file is generated when I start my SOA Suite and not when I open the JSP Page. But I'm guessing may be for the same reason, it the not calling the BPEL process.
I don't have any issues while I deploy the BPEL process or calling the BPEL Process from the console.
Thanks for any help
-Chandra -
Tomcat 6 Calling a Java Servlet from a JSP Page
Below is a very simple JSP Page that calls a Java Servlet. The question is given Tomcat security constraints, is it possible to call a servlet from a JSP and get the correct output without getting an error message? If so, how would you code the web.xml file?
c:\apache-tomcat-6.0.18
Under conf
catalina
localhost
HelloWorldExample.xml is directly under localhost
The application would have this directory structure:
webapps
HelloWorldExample
hello.jsp is directly under HelloWorldExample
Under HelloWorldExample
src
WEB-INF
classes
Under classes
jservlets
HelloWorld.java is in src folder
HelloWorld.class is in jservlets folder
HelloWorldExample.xml
<Context path="/HelloWorldExample" docBase="HelloWorldExample" debug="0"
reloadable="true" crossContext="true">
</Context>**************************
hello.jsp
<HTML>
<HEAD>
<TITLE>Hello</TITLE>
</HEAD>
<BODY>
<FONT SIZE="4">
<P>
Please enter your name:
<FORM
METHOD="Post"
ACTION="servlet/jservlets.HelloWorld">
<TABLE BORDER="3" CELLPADDING="1" WIDTH="100%" ALIGN="CENTER">
<TR>
<TD><B>Name:</B></TD>
<TD><INPUT TYPE="text" NAME="Name" VALUE="" SIZE="65"> </TD>
</TR>
</TABLE>
<P>
<INPUT TYPE="SUBMIT" VALUE="Submit">
</FORM>
</FONT>
</BODY>
</HTML>******************
HelloWorld.java
package jservlets;
import java.io.*;
import java.util.Date;
import java.util.*;
import java.text.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
PrintWriter out;
PrintWriter err;
String strName;
public void displayMessage(HttpServletRequest request, HttpServletResponse response)
throws Exception
try
if (!strName.equals("") && strName != null)
out.println("Hello " + strName + "" + "<P>");
out.println("Hello World" + "<P>");
else
out.println("Hello World" + "<P>");
catch (Exception e)
out.println("Exception: Could not display message." + "<P>");
err.println (e.getMessage () ) ;
out.println("<P>");
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
try
response.setContentType("text/html");
out = response.getWriter();
err = response.getWriter();
strName = request.getParameter("Name").trim();
out.println("<html><head><title>");
out.println("</title></head><body>");
out.println("<FORM");
out.println("METHOD=POST");
out.println("ACTION=http://localhost:8080/HelloWorldExample/hello.jsp>");
out.println("<TABLE ALIGN='RIGHT'>");
out.println("<TR>");
out.println("<TD>");
out.println("<INPUT TYPE=\"SUBMIT\" VALUE=\"Hello World Page\";>");
out.println("</INPUT>");
out.println("</TD>");
out.println("</TR>");
out.println("</TABLE>");
out.println("</FORM>");
out.println("<BR CLEAR='all'>");
out.println("<P>");
displayMessage(request, response);
out.close();
out.println("</body></html>");
catch(Throwable e)
e.printStackTrace();
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
doPost(request, response);
web.xml
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>jservlets.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping> ******************************
HelloWorld.java can be compiled by using javac.
Once compiled, HelloWorld.class would be moved to the jservlets folder.
FYI, coding the above url-pattern results in:
HTTP Status 404
The requested resource (/HelloWorldExample/servlet/jservlets.HelloWorld) is not available
The following url-pattern in the web.xml file permits the servlet to be executed but results in a null pointer exception:
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/ </url-pattern>
</servlet-mapping> **************************************************
RobinThis problem was resolved.
In hello.jsp
ACTION="servlet/jservlets.HelloWorld">
was replaced with
ACTION="servlet/HelloWorld">
Robin
Maybe you are looking for
-
How to delete the logical lines in JTextArea
Hi all, Now that I know how to find the logical line count in JTextArea as I found the following in the forum. public static int getLineCount (JTextArea _textArea) boolean lineWrapHolder = _textArea.getLineWrap(); _textArea.setLineWrap(false); double
-
Site doesn't display properly when viewed in Windows 8.1 and IE11
Web site doesn't display properly when viewed in Windows 8.1 and IE11. Site html and css validates no errors at W3C. Any ideas?
-
Exporting from FCX to other programs
How easy is it to export from Final Cut Pro X to other programs such as Pro Tools and After Effects? Have there been problems when going between FCX and these programs?
-
What exactly does am.invokeMethod() do?
Can any one please explain what exactly does this am.invokeMethod() do and I would like to ask about the setForwardURL also. regards Ram
-
OS 10.9.3 Screen freezes
Since installing OS 10.9.3 update yesterday my sceen has partiall locked up three times forcing a reboot each time. The lockup comes without warning sometimes in the middle of a curser move. The main screen locks up in the sense that the cursor move