Calling a Weblogic Servlet from a CGI
Hello,
I need to call a WL servlet from a CGI and having problems with the URL
enconding.
It's necessary to add a null character to the URL in the CGI script?
Thanks in advance
[email protected]
Hi!
I believe U can call ur servlet by appending "servlet" just before servlet1 .
That is
ur URL should be
http://<host:port>/servlet/servlet1/<File .........>
I was facing the same problem and it worked fine..........
Why JDev9i appends "/servlet" and how to remove this is so that I can have whatever path I can is still a mystery..
If u have a work around. Do share with me...
Cheers
Abhishek
mail: [email protected]
Similar Messages
-
Calling 3 different servlets from a single servlet
hi all,
i am in lot of soup...i am new to servlets,etc....so help me pls.
i need to call 3 different servlets from one servlet. all 3 servlets that i want to call perform different functions and execute queries on the database.
what i am trying to do is:
there is an html page that call a servlet called authenticate.java.(whose code is at the bottom of this page).
the servlet authenticate.java should authenticate a user according to the password and username supplied in the html page.
MAINLY:-
i need to display 3 buttons to the authenticted user. those 3 buttons each should call 3 different servlets, which do different things.
now in authenticte.java i set certain information in the session using session.putValue();
further, whatever servlet is called, i need to use that information i set into the session...using session.getValue().
PLS TELL ME HOW TO DO THAT...ALSO C IF THE BELOW CODE IS OK.
ALSO TELL ME HOW TO END A SESSION. ALSO DO SERVLETS SUPPORT SESSIONS?
I AM USING jdk1.3 and jsdk2.0.
* Authenticate.java
// this places all user variables in session
//to access use session.getAttribute
//dispatcher stuff
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.sql.*;
import java.io.*;
import java.util.*;
* @author Gudiya
* @version
public class Authenticate extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
HttpSession session = request.getSession(true);
Connection con=null;
String sessionid;
String deptcode;
String desig;
String add1;
String add2;
String contname;
PrintWriter out = response.getWriter();
try
{System.out.println(1);
response.setContentType("text/html");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:SACFA","","");
System.out.println("connection established");
catch(ClassNotFoundException e){
System.out.println("database driver not found");
System.out.println(e.toString());
catch(Exception e){System.out.println(e.toString());
String username=request.getParameter("username");
String password=request.getParameter("password");
try{
System.out.println(2);
PreparedStatement stmt=con.prepareStatement("SELECT * FROM AUTHENTICATION,mb_add where AUTHENTICATION.NAME=? AND AUTHENTICATION.PASSWORD=? AND mb_add.DEPT_NAME=?");
stmt.setString(1,username);
stmt.setString(2,password);
stmt.setString(3,username);
ResultSet rs=stmt.executeQuery();
System.out.println(3);
boolean rowfound=false;
rowfound=rs.next();
if (rowfound==true)
sessionid=session.getId();
System.out.println(sessionid);
System.out.println(4);
session.putValue("user",username);
rs.beforeFirst();
while (rs.next())
System.out.println(5);
deptcode=rs.getString("DEPT_CODE");
desig=rs.getString("DESIGNATION");
add1=rs.getString("ADDRESS1");
add2=rs.getString("ADDRESS2");
contname=rs.getString("NAME");
session.putValue("dept_code",deptcode);
session.putValue("designation",desig);
session.putValue("address1",add1);
session.putValue("address2",add2);
session.putValue("cont_name",contname);
System.out.println(6);
} out.println("<html>");
out.println("<head>");
out.println("<title>Successful Login Screen</title>");
out.println("</head>");
out.println("<body bgcolor='ORANGE'>");
out.println("WELCOME SACFA MEMBERS FROM "+ username);
//print decorative html statements here
out.println(" SELECT ANY ONE ACTION:-");
//out.println("<form Action="+"\"servlet/noc\""+" method =post>");//call for your noc servlet
//print decorative html statements here
out.println("<INPUT TYPE=submit VALUE='GENERATE NOC' NAME='NOC'>");
out.println("</form>");
//print decorative html statements here
//out.println("<form Action="+"\"servlet/comments\""+" method =post>");//call for your comment servlet
out.println("<INPUT TYPE=submit VALUE='ENTER/ MODIFY COMMENTS' NAME='COMMENTS' >");
out.println("</form>");
//print decorative html statements here
// out.println("<form Action="+"\"servlet/bye\""+" method = post>");
out.println("<INPUT TYPE=submit VALUE=EXIT NAME=EXIT >"); //place javascript fucction for exiting window
out.println("</form>");
out.println("</body>");
out.println("</html>");
con.close();
} catch( SQLException e){ }
out.close();}
THANK YOU,
REGARDS,
ASHNAHi Ashna,
You have use three different forms for three buttons. But I think all are commented one.It will also work if you uncomment it.
Else you can use only one Form without giving action in form tag. Use normal buttons instead of submit type buttons & call different JavaScript functions on onClick event for each button.
Try this out.
Ajay -
Calling a weblogic control from a MDB in 10.3
We have a requirment of calling a weblogic control from a MDB. There is a option to call this using Controls.instantiate. However, the secound level controls are not getting called. It means, I have a Facade, DAO and DB controls [Tipically the Design patern implementation]. I am calling the DAO from Facade and the DAO calls DB.
when i am trying to call a Facade from a MDB using the Controls.instantiate, the facade is getting called but depending controls are not getting called.
Please suggest how we can approch this. Is there any way to call a control from a MDB using anotations?
Thanks,Hi Srini,
it supports but you need to upgrade correctly.
follow this link
Beehive Applications
after upgrade if you found some error like classnotfound error.
If those are the errors you were also experiencing, then please follow one of these options to resolve this issue:OPTION
1:Identify all the JARs that contain the beehive classes and explicitly add the jar files to the classpathOPTION
2:When you created the domain (if you used the Config Wizard), do you make it a "Workshop" domain? If not, try that.That should deploy the Workshop framework (Beehive controls, NETUI, etc) libraries as shared libraries. Then these libraries should be referenced in your applications weblogic.xml and weblogic-application.xml.
regards,
Kal -
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 -
Calling this simple servlet from command line -- ERRORS!
Below is my servlet. I call from command line via:
java BatchServlet
and I get:
Exception in thread "main" java.lang.NoClassDefFoundError: BatchServlet
IS there a reason for this
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
public class BatchServlet extends HttpServlet implements Runnable{
static Thread t = null;
public void init(ServletConfig c) throws ServletException{
super.init(c);
if (t==null){
t = new Thread(this);
t.start();
public void run(){
while (true){
try{
Thread.sleep(5000);
}catch (InterruptedException ie){
ie.printStackTrace();
System.out.println("Wake up");Same error with this little prog.....
Notice main method
package wch.util;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
public class test {
public void main(){
System.out.println("test"); -
Calling remote machine servlet from applet
I got an error when I calling a remote machines servlet. I am calling from applet which is downladed by pluggin.
can any body tell me what is the reason the applet is not calling this servlet ?
what do i do to solve this problem ?
DineshDinesh
Enable the Java console (Control Panel, Java Plug-In, Basic, Show Java Console, Apply)
The error message might give you some help.
Regards -
Problems calling Java Servlets from HTML pages Online
Hello
I have created a Web site using Java Servlets, and have acquired some servlet enabled web-space however i am having some difficulty in calling the actual servlets from the HTML pages i was using the line of code as follows
http://localhost:8080/servlet/....
followed by the name eg.
http://localhost:8080/servlet/Login
however this doesn't seem to be working i have also tried using the exact address of the servlet but this didn't work either
i.e ..servlet/Login.java
I was wondering would anyone have any idea as in how the servlets should be called
Thanks very muchOnce you write the Servlet code, you have to compile and put the classes in the server classpath. To refer these servlets from your pages, you have to configure them in the server configuration(typical a xml file). There you define how you are going to refer to the servlet(/servlet/Logon) and the correponding class.
-Mak -
Call a servlet from Faces Portlet in Websphere
Hi All,
I have created a JSR-168 Faces Portlet project and using RAD(IDE) and WebSphere Portal server.
I want to call a servlet from my jsf portlet.But i do not know where to place my servlet in the project directory.And how to invoke a call to my servlet from my portlet.
Please help me find an answer.
Best Regards,
Pallavihi Pallavi,
Yes you can do that, what you have to do is you can get the ExternalFacesContext and forward your request to the servlet, you have entry for your servlet in web.xml...
I am sure about it but you can try this
Hope it will work.
Surya -
Is it possible to call a class/servlet from a front-end web page (web page is in HTML form not java form) given that I created my servlet to be executed per class? If there is, can you give me a sample code snippet on how to do this?
An example on how I call a class in my servlet:
coordinate c = new coordinate();
boolean a = c.plot(x,y);
//do somethingBackground:
I have already finished creating the server side code for a website and I chose to call a class inside the doPost() method. The class called will be responsible for executing the logic.
The problem arrives when the web designer created a webpage that requires more than 1 function to be called per page. Since I'm using doPost() which requires the form to be submitted, is there a way to know which submit button is clicked and thus execute the correct function?
I have a plan that I can fall back to which is to change my code so that it will read variables from the URL instead of thru a method call, but it will take more time since there are a lot of methods. I just thought I ask here if there is a way to accomplish the above so that I can save my code from this mess.
Thanks,My servlet is structured in a way that it calls a method with values that it acquires from the webpage. (The initial plan was to enclose the HTML inside a servlet, but was changed so now I need to incorporate my servlets/services inside the HTML)
Like in my example, on the coordinate class x and y are acquired from input boxes located in the web page then invoked the method plot(x,y). Since it will be HTML main and servlet sub, I need a way to call plot(x,y) from an HTML page. Or are you saying that my option would be to just create an intermediary servlet that would acquire the input and then call my class to process. -
Submit URL to Servlet from javaBean
I am trying to make a call to servlet through URL in my javabean and its not working out. calculateFedexRates class is working fine. If I call the same servlet from oracle PL/sQL package using util_http packge, it works just fine. But here in java bean I get error as follows:
I just dont know what is wrong am I doing? Please help.
Thanks.
here is my java bean.
---------------------public class submiturltoservlet {
public static void main(String[] args) {
try {
String data = URLEncoder.encode("ds", "UTF-8") + "=" + URLEncoder.encode("0", "UTF-8");
data += "&" + URLEncoder.encode("weight", "UTF-8") + "=" + URLEncoder.encode("10.03", "UTF-8");
data += "&" + URLEncoder.encode("fromState", "UTF-8") + "=" + URLEncoder.encode("IL", "UTF-8");
data += "&" + URLEncoder.encode("fromZip", "UTF-8") + "=" + URLEncoder.encode("60133", "UTF-8");
data += "&" + URLEncoder.encode("toState", "UTF-8") + "=" + URLEncoder.encode("IL", "UTF-8");
data += "&" + URLEncoder.encode("toZip", "UTF-8") + "=" + URLEncoder.encode("60601", "UTF-8");
data += "&" + URLEncoder.encode("shipDate", "UTF-8") + "=" + URLEncoder.encode("2009-02-05", "UTF-8");
URL url = new URL("myurl/fedex/getFedexRates?weight=10.03&fromState=IL&fromZip=60133&toState=IL&toZip=60601&shipDate=2009-02-05");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
((HttpURLConnection)conn).setRequestMethod("GET");
conn.setUseCaches(false);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
System.out.println("Response: " + line);
wr.close();
rd.close();
} catch (Exception e) {
System.out.println("print out a stack trace and exit");
e.printStackTrace();
} // end of main
} // End of class
here is my servlet.
public class getFedexRates extends HttpServlet {
public void init() {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String weight = request.getParameter("weight");
String fromState= request.getParameter("fromState");
String fromZip= request.getParameter("fromZip");
String toState= request.getParameter("toState");
String toZip= request.getParameter("toZip");
String shipDate= request.getParameter("shipDate");
calculateFedexRates calculatefedrate = new calculateFedexRates();
response.setContentType("text/plain");
PrintWriter out = response.getWriter();
out.println(calculatefedrate.calculate(weight,fromState,fromZip,toState,toZip, shipDate));
out.close();
out.flush();
public void destroy() {
Error I get :
java.io.IOException: Server returned HTTP response code: 405 for URL: http://myurl/fedex/getFedexRates?weight=10.03&fromState=IL&fromZip=60133&toState=IL&toZip=60601&shipDate=2009-02-05
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:800)
at submiturltoservlet.main(submiturltoservlet.java:34)HTTP status code 405 means "method not allowed". So the other side doesn't support GET or POST request.
I am not sure what the request method is after all. The setDoOutput(true) triggers POST, but you're forcing it to GET afterwards. Why this? It look like that you rather want a GET, so leave the setDoOutput(true) away and that other line too. If it still returns a 405, then you should probably be using POST rather than GET. In this case use setDoOutput(true) and write the query string to the body of the request rather than in URL. -
URLConnection returns NULL when called from within a weblogic servlet
The following code snippet works when executed outside of weblogic, but does
not work from within a weblogic servlet instance.
URL u = new URL("http://" + ipString + newString.toString());
URLConnection uc = u.openConnection();
BufferedReader in = new BufferedReader (new InputStreamReader(uc.getInputStream()));
String response = "", response2 = "";
while(response2 != null)
response = ((response2 = in.readLine()) == null) ? response : response + response2;
The response is quite big. When this code is executed from within a weblogic servlet instance,
in.readLine always returns a null right away. Yet a TCP/IP trace shows that the packets are coming
back to my NT machine.
Other info:
Inside of weblogic:
u's handler is of type weblogic.net.http.Hanlder
uc is of type weblogic.net.http.HttpURLConnection
Outside of weblogic:
u's handler is of type sun.net.www.protocol.http.Handler
uc is of type sun.new.www.protocol.http.HttpURLConnection
Weblogic V4.51. Running on NT.
Attempted the following to no avail:
1. installing sp11
2. changing the security to permission java.security.AllPermission;
3. adding the following calls : uc.setRequestProperty("Content-Type", "text/xml");
uc.setDoInput(true);
uc.setDoOutput(true);
4. Started playing around with modifying the java.protocol.handler.pkgs system property,
but I shouldn't have to do this.
Any help would be appreciated.There are some problems with the WL implementations of certain protocols.
WL hides the Sun implementations when you are in the WebLogic server. Here
is an a solution that was posted to a similar problem:
Https is an add-in so to speak. Try this before you create your url:
System.setProperty ("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
// add the default security provider (again, in JSSE1.0.1)
int iap = java.security.Security.addProvider(new
com.sun.net.ssl.internal.ssl.Provider() );
dennisNote how the code overides the WL setting which overode the Sun setting.
Cameron Purdy
[email protected]
http://www.tangosol.com
WebLogic Consulting Available
"Brian Howell" <[email protected]> wrote in message
news:[email protected]...
>
The following code snippet works when executed outside of weblogic, butdoes
not work from within a weblogic servlet instance.
URL u = new URL("http://" + ipString + newString.toString());
URLConnection uc = u.openConnection();
BufferedReader in = new BufferedReader (newInputStreamReader(uc.getInputStream()));
>
String response = "", response2 = "";
while(response2 != null)
response = ((response2 = in.readLine()) == null) ? response : response +response2;
The response is quite big. When this code is executed from within aweblogic servlet instance,
in.readLine always returns a null right away. Yet a TCP/IP trace showsthat the packets are coming
back to my NT machine.
Other info:
Inside of weblogic:
u's handler is of type weblogic.net.http.Hanlder
uc is of type weblogic.net.http.HttpURLConnection
Outside of weblogic:
u's handler is of type sun.net.www.protocol.http.Handler
uc is of type sun.new.www.protocol.http.HttpURLConnection
Weblogic V4.51. Running on NT.
Attempted the following to no avail:
1. installing sp11
2. changing the security to permission java.security.AllPermission;
3. adding the following calls : uc.setRequestProperty("Content-Type","text/xml");
uc.setDoInput(true);
uc.setDoOutput(true);
4. Started playing around with modifying the java.protocol.handler.pkgssystem property,
but I shouldn't have to do this.
Any help would be appreciated. -
Problem while calling servlet from java bean
I am trying to call a servlet from java bean in cep.
My java bean:
package com.bea.wlevs.example.algotrading;
import com.bea.wlevs.ede.api.StreamSink;
import com.bea.wlevs.example.algotrading.event.MarketEvent;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class MarketEventBean implements StreamSink {
String s=null;
public void onInsertEvent(Object event) {
if (event instanceof MarketEvent) {
MarketEvent marketEvent = (MarketEvent) event;
try {
JAXBContext cxt = JAXBContext.newInstance(MarketEvent.class);
Unmarshaller unmarsh = cxt.createUnmarshaller();
StringReader strReader = new StringReader(marketEvent.getString_1());
MarketEvent obj = (MarketEvent) unmarsh.unmarshal(strReader);
s=obj.getSymbol();
System.out.println("data: " + s);
} catch(Exception e) {
e.printStackTrace();
try {
System.out.println("test1");
URL url = new URL("http://172.18.21.94:7001/AppServletrecv-Model-context-root/ReceiveServlet");
URLConnection conn = url.openConnection();
System.out.println("test2");
conn.setDoOutput(true);
System.out.println("test3");
BufferedWriter out =
new BufferedWriter( new OutputStreamWriter( conn.getOutputStream() ) );
out.write("symbol="+s);
System.out.println("test4");
out.flush();
System.out.println("test5");
out.close();
System.out.println("test6");
BufferedReader in =
new BufferedReader( new InputStreamReader( conn.getInputStream() ) );
System.out.println("test7");
String response;
while ( (response = in.readLine()) != null ) {
System.out.println( response );
in.close();
catch ( MalformedURLException ex ) {
// a real program would need to handle this exception
catch ( IOException ex ) {
// a real program would need to handle this exception
My servlet code:
package model;
import javax.servlet.http.HttpServlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ReceiveServlet extends HttpServlet {
private final static String _SYMBOL = "symbol";
public void doPost(HttpServletRequest request, HttpServletResponse response) {
* Get the value of form parameter
// private final static String USERNAME = "username";
String symbol = request.getParameter( _SYMBOL );
* Set the content type(MIME Type) of the response.
response.setContentType("text/html");
* Write the HTML to the response
try {
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title> A very simple servlet example</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello " + symbol +"</h1>");
out.println("</body>");
out.println("</html>");
out.close();
} catch (IOException e) {
Web.xml:
<?xml version = '1.0' encoding = 'windows-1252'?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
<servlet>
<servlet-name>ReceiveServlet</servlet-name>
<servlet-class>model.ReceiveServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ReceiveServlet</servlet-name>
<url-pattern>/ReceiveServlet</url-pattern>
</servlet-mapping>
</web-app>
My servlet is running in weblogic server.
But when I am running this program in weblogic server side there is no log.
Edited by: 856272 on Jun 23, 2011 6:43 AMI would run both sides in a debugger and see what code is getting invoked
-
Very urgent: call servlet from JSP
Hello,
I'm facing a problem in invoking a servlet from a JSP having the JSF components.
The application has a text field to implement ajax for search functionality in the database .I have written a servlet to make the database connection and fire the querry.
Ajax implementation in a js file is called on every keyup event in the jsp file,and
a call is given to the servlet from the ajax methode.
The function in the js file is as follows:-
function getPersonByFirstNameXML( firstName ) {
if (!firstName) {
clearPersonByFirstNameXML();
} else {
var url = BASE_URL + "/servlet/get_PersonsXML";
alert(url);
return new AJAXRequest("post", url, "firstName=" + encode(firstName), processGetPersonByFirstNameXML);
}Im getting the myAJAX.status value as 500.
I think I'm not able to access the servlet properly.
what changes do i need to make in the we.xml file ?
and what should be the url to be passed.
Please provide me a sloution to the above problem as it is very urgent else if anybody is aware of a readymade JSF componet with search functionality freely available please let me know.
PS:
The sample application named RedirectionExample which makes use of a servlet and would be of help to you. You can find the tutorial on the following page:
http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/sampleapps.html
is not available as stated in some of the suggestions by Author: mayagiri
Thanks for any help.
Abhithe status 500 generally means either HTTP server internal error or that execution of CGI script or servlet aborted with error.
It can be reasonably supposed that the request reaches the servlet, ie. that "url" value points to some existing servlet, otherwise most probably the status value would be 404.
To test that the servlet is working i'd try to access it using some simple html page with form like this (with {BASE_URL} replaced by real value):
<form method=post action={BASE_URL}/servlet/get_PersonsXML>
<input type=text name=firstName>
<input type=Submit>
</form> -
Calling a servlet from a Java Stored Procedure
Hey,
I'm trying to call a servlet from a Java Stored Procedure and I get an error.
When I try to call the JSP-class from a main-method, everything works perfectly.
Java Stored Procedure:
public static void callServlet() {
try {
String servletURL = "http://127.0.0.1:7001/servletname";
URL url = new URL(servletURL);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setRequestProperty("Pragma", "no-cache");
conn.connect();
ObjectInputStream ois = new ObjectInputStream(conn.getInputStream());
Integer client = (Integer)ois.readObject();
ois.close();
System.out.println(client);
conn.disconnect();
} catch (Exception e) {
e.printStackTrace();
Servlet:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Integer id = new Integer(10);
OutputStream os = response.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(id);
oos.flush();
oos.close();
response.setStatus(0);
Grant:
call dbms_java.grant_permission( 'JAVA_USER', 'SYS:java.net.SocketPermission','localhost', 'resolve');
call dbms_java.grant_permission( 'JAVA_USER','SYS:java.net.SocketPermission', '127.0.0.1:7001', 'connect,resolve');
Package:
CREATE OR REPLACE PACKAGE pck_jsp AS
PROCEDURE callServlet();
END pck_jsp;
CREATE OR REPLACE PACKAGE BODY pck_jsp AS
PROCEDURE callServlet()
AS LANGUAGE JAVA
NAME 'JSP.callServlet()';
END pck_jsp;
Architecture:
AS: BEA WebLogic 8.1.2
DB: Oracle 9i DB 2.0.4
Exception:
java.io.StreamCorruptedException: InputStream does not contain a serialized object
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java)
The Servlet and the class work together perfectly, only when I make the call from
within the database things go wrong.
Can anybody help me.
Thank in advance,
Bart Laeremans
... Desperately seeking knowledge ...Look at HttpCallout.java in the following code sample
http://www.oracle.com/technology/sample_code/tech/java/jsp/samples/jwcache/Readme.html
Kuassi -
Error in holder-of-key : calling a secure webservice from weblogic instan
Hi,
I am getting following error . Can somebody decrypt this for me ?
ava.rmi.RemoteException: SOAPFaultException - FaultCode [{http://schemas.xmlsoap.org/soap/envelope/}Server] FaultString [Failed to add Signature.] FaultActor [null]No Detail; nested exception is:
weblogic.wsee.jaxrpc.soapfault.WLSOAPFaultException: Failed to add Signature.
at services.SSOTestHelloWorld_Stub.hello(Unknown Source)
at deloitte.iit.webservices.CallWebService.callService(CallWebService.java:31)
at jsp_servlet.__clienttest._jspService(__clienttest.java:82)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:408)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:318)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: weblogic.wsee.jaxrpc.soapfault.WLSOAPFaultException: Failed to add Signature.
at weblogic.wsee.codec.soap11.SoapCodec.decodeFault(SoapCodec.java:355)
at weblogic.wsee.ws.dispatch.client.CodecHandler.decodeFault(CodecHandler.java:115)
at weblogic.wsee.ws.dispatch.client.CodecHandler.decode(CodecHandler.java:100)
at weblogic.wsee.ws.dispatch.client.CodecHandler.handleFault(CodecHandler.java:88)
at weblogic.wsee.handler.HandlerIterator.handleFault(HandlerIterator.java:309)
at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator.java:269)
at weblogic.wsee.ws.dispatch.client.ClientDispatcher.handleResponse(ClientDispatcher.java:213)
at weblogic.wsee.ws.dispatch.client.ClientDispatcher.dispatch(ClientDispatcher.java:150)
at weblogic.wsee.ws.WsStub.invoke(WsStub.java:87)
at weblogic.wsee.jaxrpc.StubImpl._invoke(StubImpl.java:337)
... 18 more
Caused by: weblogic.xml.crypto.wss.WSSecurityException: Failed to add Signature.
at weblogic.wsee.security.wss.SecurityPolicyDriver.processIntegrity(SecurityPolicyDriver.java:240)
at weblogic.wsee.security.wss.SecurityPolicyDriver.processOutbound(SecurityPolicyDriver.java:74)
at weblogic.wsee.security.WssClientHandler.processOutbound(WssClientHandler.java:71)
at weblogic.wsee.security.WssClientHandler.processRequest(WssClientHandler.java:55)
at weblogic.wsee.security.WssHandler.handleRequest(WssHandler.java:74)
at weblogic.wsee.handler.HandlerIterator.handleRequest(HandlerIterator.java:141)
at weblogic.wsee.handler.HandlerIterator.handleRequest(HandlerIterator.java:107)
at weblogic.wsee.ws.dispatch.client.ClientDispatcher.dispatch(ClientDispatcher.java:132)
... 20 moreHi Stephen,
Using a registry, for example UDDI [1], would be one solution. WLS has
a complete UDDI implementation builtin [2] for this purpose.
You are correct, you need to pass the service address location found in
the <service> section of the WSDL.
Hope this helps,
Bruce
[1]
http://www.uddi.org/
[2]
http://e-docs.bea.com/wls/docs81/webserv/uddi.html
Stephen Kurlow wrote:
>
I am not sure what I need to do to be able to call a remote webservice (runs on
another weblogic server instance running on another machine in the same network)
from within a webservice. I have 2 wsdl files and I have created webservice controls
from them. I have successfully written code in the first webservice to instantiate
the parms to the 2nd webservice and invoked the 2nd webservice when both webservices
are deployed to the same weblogic server instance. So i can see the params being
marshalled and unmarshalled in the test browser.
Now how do I install the 2nd webservice on another weblogic server instance and
instruct the 1st web service to call the 2nd webservice residing on another weblogic
server instance? I presume some kind of lookup (url?) is needed and is it via
what is contained in the wsdl file?
Thanks in advance,
Stephen Kurlow
Maybe you are looking for
-
How can I make a FlashAlbumExporter background transparent?
I really like the very cool FAE (as suggested on this most excellent forum) but the gui offers no choice as for background opacity. A little search on the net reveals a few ideas but none of them seem to work. I am using the following iframe code in
-
Error:SAP NetWeaver 7.01 ABAP Trial Version
Hi, While installing SAP NetWeaver 7.01 ABAP Trial Version I am getting following error in the logfile generated. Kindly help if someone has encountered the same and has been able to rectify it. Looking for your immediate response. Regards, Ratna. (N
-
HP laserjet CM1015 won't print fonts in color
I have some text that is in blue and green but it prints in black instead. I also have clip art on the page and that prints in color with no issues. Why wont the text print in color when the clip art will? That obviously tells me there is no issue
-
HT1212 will i loose all the photos on my phone if it hasnt been backed up?
will i loose all the photos on my phone if i reset it with a hard reset?
-
After changing my apple ID I go in and I continue to get an error message.