Executing javascript command in jsp method
here's the situation....
I have a jsp page with three buttons at the bottom. One button reads
"Save and Continue", another reads "Save and Quit" and the third reads
"Quit". OnClick the page executes a java method that does
verification for form objects, etc. THe problem here is the only way
I know to close a window is self.close(); in javascript.
Does anyone know how I may be able to excecute the method on click and
then have that method close the window? IS this possible?
No, I was not getting an error, but the file that I was executing was suppose to create two files and the two files were not created.
However, I have since discovered that I needed to have write permission on the directory that I was writing too. So, it is working now, but thanks for responding.
Similar Messages
-
Execute javascript command in acrobat debugger on leopard macbook
I can't seem to find the key combination to execute a javascript command in the acrobat javascript debugger on my leopard macbook.
I tried command+return, control+return, nada.
Anyone know what is going on?
I have everything enabled in preferences.
DavidThe Macintosh keyboard does not have a true "Enter" key any more - not on the MacBook Pro or the iBooks. Modifier keys do not seem to work either. I've turned on the System Prefs > Keyboard & made it appear in the top Menu Bar. From this menu choose "Show Keyboard Viewer" to see how keys + Return are displayed. Only the Function key changes the Return key. Function + Delete is a forward delete. But Function + Return is just another Return. So any highlighted text is deleted! Command + Return stays on the same line and selected text remains. I will try KeyRemap4MacBook utility then consider buying a USB numeric keypad. Urggh.
-
Issues with Executing Javascript command in Captivate
Hi,
I am having issues with executing javascript for a button in adobe captivate 5. Let me explain what I am trying to do. I am working on a WBT that has three skill checks throught the course. These skill checks are not graded or tracked for completion. I currently have an image button that has the command "Open another project" The first image button is pointed to SkillCheck1 and I have the html file and swf file in the published root folder. This currently works fine.
However I want to use javascript to open a new window 800X600 with not toolbars at the top. I got this part working with the code below:
window.open('http://www.adobe.com','mywin',
'left=40,top=40,width=800,height=600,toolbar=1,resizable=0');
My only problem is, once the popup opens, my WBT goes to a page that says [object] and thats it. I am uploading two images to show what I have. Can someone help resolve my issue of the WBT going toOk so I took this link and viewed over it. I am new to Javascript and know very little about it. Therefore this script kind of makes no sense to me.
<script language="JavaScript"><!--
var windowHandle = '';
function myOpen(url,name,attributes) {
windowHandle = window.open(url,name,attributes);
//--></script>
<a href="javascript:myOpen('page.htm','windowName','height=100,width=100')">text link</a>
I chose the option to exectute javascript. Does captivate need all of this including <script language=JavaScript"> Here is how I edited the script. Should I make any changes to what is in bold?
var windowHandle = '';
function myOpen(url,name,attributes) {
windowHandle = window.open(url,name,attributes);
<a href="javascript:myOpen('http://www.adobe.com','Adobe Website','height=600,width=800')">text link</a> -
How can I execute Linux commands through a JSP page on a Red Hat Linux 6.1 Machine using Tomcat 3.0
Please Mail your answer
[email protected]Hi Nick,
Thankx a lot, for suggestion,
I wanted to make a page which gives me a text box to write a command and below it shows the result of that command,
Say , I m in directory "/home/dhiraj"
and I write in command text box : "pwd"
it should give me the currrent path in result , which I can show in form of HTML as Results ,
(may be in a String form..)
same way if I write in command box : "ls -l"
it should Return me (say a String) the directory listing of the current path in result,
I have already tried the Runtime & Process class ,
Runtime rt = Runtime.getRuntime();
Process p =null;
p = rt.exec("command here");
p.waitFor();
it has following problems:
1) This way I m not able to get the result ..
2) I tried to make a zip file via my program it did not threw any exception , but could not execute...
I was confused is it 'coz of permission ( rights problem) or some programmatical error as the same program runs via a Java Class file ..
desperately waiting for ur suggestions
Dhiraj Agrawal
MCA student and a Trainee in a local Software House
reply to: [email protected] -
Need to execute Linux Commands in JSP
Hi I am Srinivas,
I am new to this forum,
{color:#ff0000}I want to execute Linux Commands(which is remotely connected through putty) in a JSP Page.{color}
{color:#0000ff}My requirement is to display df -h output on a JSP page.{color}
This is because we will monitor disk space at regular intervals.
Can anyone help me in this regard.
Thanks & Regards
Srinivas V.
Edited by: Srini-XIUS on Mar 24, 2008 2:06 AMI think you might need the java 'robot' class.
However, a JSP page displayed on a browser is running in a secure enviornment that will probably not let you access the computer its running on. Instead, create a serlvet back on the server that runs the robot class. The servlet will send the data to the jsp page for display. The jsp page can send commands to the servlet which will execute it via its robot class. -
Problem when trying to execute OS Command in Notification Method
Hi gurus,
I am using EMGC 10.2.0.2 on windows XP, I have created a Notification method with a OS Command which is a batch file which intern calls a perl script to send a mail notification. When there is an alert the Alert History logs says that 1 OS Command is executed and show s the bat file name, but I am not getting any mail as expected. I have given the absolute path for bat file. What could be the reason for this and where can I find the logs for this knowing the status of OS command execution details.
Thanks,
Ashok ChavaHi bazza,
My perl script is running fine in isolation no issues with that. I thought it may be becasue of the some time out issues then I have increased time from 30 second to 120 seconds by changing the property value "em.notification.os_cmd_timeout" in emoms.properties but with out any success. I dont have any logging messages put in the perl script I will check with that also. I have checked bat file by giving some logging messages the bat file eexcuting properly.
Thanks,
Ashok Chava. -
Ho to execute dbschema command in jsp
hi
i am using informix as database server.In that dbschema is a utility that gives schema of table
This command i have to excecute in jsp but i dont how?hey. Im actually using servlets and i know this isnt the right forum but i was given this url to come look here as it is similar to something i need.
I just need to execute a batch file that sync's down a load of files and directories from perforce. i dont need to print them or see them i just nned it down so im assuming i will need more than just
Process p = Runtime.getRuntime().exec("C:\\sync.bat");
at the top of my code to run the batch file. does anyone have any idea what else i will need. -
I want to execute a batch file which is located at d:\build from a jsp
I also want to give parameters to batch file.
Actually my batch file is demo.bat and i want to execute this command via jsp
demo Compile devin a word - don't. that's not what jsps are for.
you sound confused about where jsps actually run. get client and server straight in your head and then think about it again.
% -
Executing "at" command of UNIX through JSP
Friends,
1. "at" command in UNIX execute Unix command at a scheduled time. 2. For each user there will be a table maintained internally which can be accessed by "at" with "-l" argument.
3. A mail will be sent to the owner with the output of the commands as a message.
I tried to run the "at" command of Unix in JSP, which gets succesfully executed in Oracle 10g App Server container (Installed in Solaris machine). I have tested the successful execution of command with the log file. But I haven't got any mail for the output. If anyone had any idea, please help me.
The code I have wtitten is
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(new String[] {"sh","-c","at 2115 Dec 7 < /export/home/usr1/abc.sh"});
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
logger.info("<ERROR>");
while ( (line = br.readLine()) != null)
logger.info(line);
logger.info("</ERROR>");
int exitVal = proc.waitFor();
logger.info("Process exitValue: " + exitVal);
My doubts are:
1. Who is the owner of the output of "at"command, which gets executed under Oracle 10g App Server container?
2. If no one is the owner, then where will the output of "at" command will go?
3. Is there any other way to execute "at" command of UNIX in java program? If so, then please help me.
Thanks in advance.
regards
Nandha Kumar.MI would imagine the process call out will be under the guise of the process owner of the OC4J instance which executing the call.
Have you seen anything different.
cheers
-steve- -
Hi All,
I'm a new developer in JSP. I'm just curious about Connecting to FTP Server by JSP. Can JSP use to execute ftp command or execute to FTP server? I want to display the list of files in directory on the ftp server. So, Please suggest your initiative or show the simple code for implement it.
Regards,
catjomJavaWorld published an article about this topic. It is called "Java FTP client libraries reviewed" and it can be found here :
http://www.javaworld.com/javaworld/jw-04-2003/jw-0404-ftp.html
Best regards
Jean-Pierre Norguet
Jean-Pierre Norguet
JavaWorld Press
http://wasa.ulb.ac.be/jp.html -
Hi,
I'm new to JSP. I'm just curious whether is there a utility in Java that we can use to execute unix command?
thanks.Hi,
You can try this,
import java.io.*;
public class test
public static void main(String args[]) {
try {
Process ps = Runtime.getRuntime().exec("ls -al");
BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(ps.getOutputStream()));
bw.write("1");
bw.flush();
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
br.close();
bw.close();
System.out.println(ps.exitValue());
catch(Exception e) {
System.out.println(e);
Hope that helps.
Regards,
Senthil Babu
Developer Technical Support
SUN Microsystems
http://www.sun.com/developers/support/ -
Unable to execute javascript from backing bean
Hello experts, I want to execute javascript function from backing bean method.
In my .jsff page, I have added the javascript as :
<jsp:root ..... >
<af:resource type="javascript" >
function fileDownloadJS() {
alert(" tesing js from backing bean");
</af:resource>
</jsp:root>
in my backing bean method :
public void callJSfuntion(ActionEvent actionEvent) {
RenderKit rk = FacesContext.getCurrentInstance().getRenderKit();
ExtendedRenderKitService erks = (ExtendedRenderKitService) Service.getService(rk, ExtendedRenderKitService.class);
erks.addScript(context, "fileDownloadJS();");
I have table in my .jsff page, inside table column, I have command link and when I click the link, I am invoking bean method :
<af:table ....>
<af:column sortProperty="title" sortable="true"
headerText="File name" width="250px" id="Title"
clientComponent="true">
<af:commandLink id="cl1" actionListener="#{MyBean.callJSfuntion}" clientComponent="true">
<af:outputText value="#{row.title}" id="ot1"/>
</af:commandLink>
</af:column>
.</table>
But when I run my taskflow and click on the link inside the table column, JS function is not invoked.
Absolutely no clue what is the issue.
Appreciate if you can help me out to resolve this issue. Thank you.For debugging purpose can you try :
<script type="javascript" >
function fileDownloadJS() {
alert(" tesing js from backing bean");
</script>
put it on top of the page and let me know what happens.
If it doesn't work try writing the function itself in your addScript(context, script); to see if it works. -
Error while executing jdbc commands but getting connection pool
I was not able to make a simple oracle connection and that hurts me.
The program(jsp) is...
<%@ page language="java" import="java.sql.*,java.io.*,
java.util.*,pac1.*,javax.naming.*,javax.sql.*"%>
<html>
<body>
<%
Context ctx= new InitialContext();
DataSource dsindogulf1=(DataSource)ctx.lookup("jnindogulf1");
Connection conn=dsindogulf1.getConnection();
if(conn!=null)
System.out.println(conn.toString());
else
System.out.println("sorry");
Statement st=conn.createStatement();
String string1="CREATE TABLE Authorr(col1 CHAR(10));";
st.executeUpdate(string1);
%>
</body>
</html>
If i delete the
st.executeUpdate(string1); then there is no problem I get the connection pool. That means i am getting the connection. But when i include the
st.executeUpdate(string1); there is an error which i cannot understand.. the error is
Error 500--Internal Server Error
java.sql.SQLException: [BEA][Oracle JDBC Driver][Oracle]ORA-00911: invalid character
at weblogic.jdbc.base.BaseExceptions.createException(Ljava.lang.String;Ljava.lang.String;I)Ljava.sql.SQLException;(Unknown Source)
at weblogic.jdbc.base.BaseExceptions.getException(I[Ljava.lang.String;Ljava.lang.String;I)Ljava.sql.SQLException;(Unknown Source)
at weblogic.jdbc.oracle.OracleImplStatement.execute()V(Optimized Method)
at weblogic.jdbc.base.BaseStatement.commonExecute()V(Optimized Method)
at weblogic.jdbc.base.BaseStatement.executeUpdateInternal()I(Unknown Source)
at weblogic.jdbc.base.BaseStatement.executeUpdate(Ljava.lang.String;)I(Unknown Source)
at weblogic.jdbc.wrapper.Statement.executeUpdate(Ljava.lang.String;)I(Statement.java:360)
at jsp_servlet.__test._jspService(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(__test.java:149)
at weblogic.servlet.jsp.JspBase.service(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;)V(Optimized Method)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run()Ljava.lang.Object;(Optimized Method)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;Lweblogic.servlet.internal.FilterChainImpl;)V(Optimized Method)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;)V(Optimized Method)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run()Ljava.lang.Object;(WebAppServletContext.java:6452)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Lweblogic.security.subject.AbstractSubject;Ljava.security.PrivilegedAction;)Ljava.lang.Object;(Optimized Method)
at weblogic.security.service.SecurityManager.runAs(Lweblogic.security.acl.internal.AuthenticatedSubject;Lweblogic.security.acl.internal.AuthenticatedSubject;Ljava.security.PrivilegedAction;)Ljava.lang.Object;(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(Lweblogic.servlet.internal.ServletRequestImpl;Lweblogic.servlet.internal.ServletResponseImpl;)V(WebAppServletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execute(Lweblogic.kernel.ExecuteThread;)V(ServletRequestImpl.java:2630)
at weblogic.kernel.ExecuteThread.execute(Lweblogic.kernel.ExecuteRequest;)V(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:178)
at java.lang.Thread.startThreadFromVM(Ljava.lang.Thread;)V(Unknown Source)
the steps which i have followed are... I have made a connection pool using weblogic type 4 driver in the administrative console... then i have created the data source using jndi name jnindogulf1..... but although i am getting the connection pool i am receiving error ehice executing jdbc commands
please help
thanksbabuli nayak wrote:
I was not able to make a simple oracle connection and that hurts me.
The program(jsp) is...
<%@ page language="java" import="java.sql.*,java.io.*,
java.util.*,pac1.*,javax.naming.*,javax.sql.*"%>
<html>
<body>
<%
Context ctx= new InitialContext();
DataSource dsindogulf1=(DataSource)ctx.lookup("jnindogulf1");
Connection conn=dsindogulf1.getConnection();
if(conn!=null)
System.out.println(conn.toString());
else
System.out.println("sorry");
Statement st=conn.createStatement();
String string1="CREATE TABLE Authorr(col1 CHAR(10));";
st.executeUpdate(string1);
%>
</body>
</html>
If i delete the
st.executeUpdate(string1); then there is no problem I get the connection pool. That means i am getting the connection. But when i include the
st.executeUpdate(string1); there is an error which i cannot understand.. the error is
Error 500--Internal Server Error
java.sql.SQLException: [BEA][Oracle JDBC Driver][Oracle]ORA-00911: invalid character
at weblogic.jdbc.base.BaseExceptions.createException(Ljava.lang.String;Ljava.lang.String;I)Ljava.sql.SQLException;(Unknown Source)
at weblogic.jdbc.base.BaseExceptions.getException(I[Ljava.lang.String;Ljava.lang.String;I)Ljava.sql.SQLException;(Unknown Source)
at weblogic.jdbc.oracle.OracleImplStatement.execute()V(Optimized Method)
at weblogic.jdbc.base.BaseStatement.commonExecute()V(Optimized Method)
at weblogic.jdbc.base.BaseStatement.executeUpdateInternal()I(Unknown Source)
at weblogic.jdbc.base.BaseStatement.executeUpdate(Ljava.lang.String;)I(Unknown Source)
at weblogic.jdbc.wrapper.Statement.executeUpdate(Ljava.lang.String;)I(Statement.java:360)
at jsp_servlet.__test._jspService(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(__test.java:149)
at weblogic.servlet.jsp.JspBase.service(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;)V(Optimized Method)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run()Ljava.lang.Object;(Optimized Method)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;Lweblogic.servlet.internal.FilterChainImpl;)V(Optimized Method)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;)V(Optimized Method)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run()Ljava.lang.Object;(WebAppServletContext.java:6452)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Lweblogic.security.subject.AbstractSubject;Ljava.security.PrivilegedAction;)Ljava.lang.Object;(Optimized Method)
at weblogic.security.service.SecurityManager.runAs(Lweblogic.security.acl.internal.AuthenticatedSubject;Lweblogic.security.acl.internal.AuthenticatedSubject;Ljava.security.PrivilegedAction;)Ljava.lang.Object;(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(Lweblogic.servlet.internal.ServletRequestImpl;Lweblogic.servlet.internal.ServletResponseImpl;)V(WebAppServletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execute(Lweblogic.kernel.ExecuteThread;)V(ServletRequestImpl.java:2630)
at weblogic.kernel.ExecuteThread.execute(Lweblogic.kernel.ExecuteRequest;)V(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:178)
at java.lang.Thread.startThreadFromVM(Ljava.lang.Thread;)V(Unknown Source)
the steps which i have followed are... I have made a connection pool using weblogic type 4 driver in the administrative console... then i have created the data source using jndi name jnindogulf1..... but although i am getting the connection pool i am receiving error ehice executing jdbc commands
please help
thanks
Hi. Remove the semicolon from your SQL string: stmt.executeUpdate("CREATE TABLE Authorr(col1 CHAR(10))");Joe -
Trouble trying to execute a binary from jsp
Hello,
I need to make an http request to a Solaris box that will execute a binary that exports data.
I have been connecting to the Solaris machine using putty and executing a command like this:
/usr/prms/prod/bin/exportEngine -f/usr/prms/run/work/exportEngine/input/Export_Params.xml -s09/07/2008 -e09/08/2008Now I need to let this be available to users that need to do this from a web page. I am able to do a simple move command but executing this binary doesn't work. I have been working on this for hours, I tried dropping this command to a perl script and it will execute the move command but not the binary too. I'm afraid this is a permissions issue that jsp will not let a web page execute an arbitrary binary.
The try/catch doesn't throw an exception, is there any other method that I can use to diagnose this? I'm new to jsp and Solaris, if anyone can help that would be great!
Thanks,
Jason
Here is my code so far:
<%
String myErrors = "";
try{
// This command doesn't work
//String[] command = {"sh","-c","/usr/prms/prod/bin/exportEngine -f/usr/prms/run/work/exportEngine/input/Export_Params.xml -s09/07/2008 -e09/08/2008"};
// This test command works
String[] command = {"sh","-c","mv /usr/prms/http/WebStationEE/supvops/test /usr/prms/http/WebStationEE/supvops/test_renamed"};
final Process process = Runtime.getRuntime().exec(command);
catch (Exception e){
myErrors = myErrors + e.getMessage();
%>
<html>
<body>
<%
out.println("myErrors: " + myErrors);
%>
</body>
</html>evnafets wrote:
What user is your server running as?
Does that server have permissions to run whatever script you are wanting to run?
I had a suspicion that it was a user issue. I'll look into it.
evnafets wrote:
Does this web request have to trigger the process or just pick up the results of running it?This is a process exports data from the Solaris box to a central database on a Windows box. It is automatically run daily but about one or two times a week a clerical staff person makes a mistake and the corrected data needs to be manually exported again. I have inherited this job and now I'm told that this needs to be put on a website (which is hosted on a Linux box lol) for the clerical staff to be able to plug in what day that needs to be rebuilt.
Edited by: jholland18 on Sep 11, 2008 9:14 AM
Edited by: jholland18 on Sep 11, 2008 9:24 AM -
Executing shell commands from Java.
I want to execute shell commands in Java using the Runtime.exec( String ) method.
The method works fine under Linux OS, but under Windows '98 the method didn't work at all!
For example the following call: Runtime.exec( "dir" ) throws an exception showing that the command was not completed. If I replace dir with ls under Linux all is good. What is the problem with the Microsoft Windows '98 ? Is there any solution at my problem ?!
thx in advance!hey JSarmis,
You can help me... "ls" doesn't work for me on linux.. using Runtime.exec, some commands work, others don't... you may hold the key to what i need? How did u get "ls" to work?
Maybe you are looking for
-
RESCCC - Generate cost collector as background job.
Hello, I am trying to generate the cost collector. normally this is a two screen procedure. In the first screen I input the parameters and then execute it. In the next screen the list of cost collectors appear with the red & white circle icon at the
-
Problem in calling JSP page from a servlet
can anyone please tell me how to call a JSP from servlet? My code is: ServletContext sc = this.getServletContext(); RequestDispatcher rd = sc.getRequestDispatcher("./Welcome.jsp");
-
This is a problem that is causing major tears
At the beginning of the year i bought a brand new iphone 5s with 32 GB!!! I barely have any apps, yes many pictures but so what? and some songs. However, i still get a message saying that I dont have anymoer available storage. I dont get how this is
-
Hello to all, Within my corporate environment, we have a case where an email account to be used by several people, type a group, like committee, and when one would use this account was recorded who sent this email, within the capabilities of GroupWis
-
Dear All, I have defined a new output type in PO, which is used in FAX. I have a requirement that the title of FAX can be changed and displayed as PO number. How can I do the customizing to realize the function? Thanks a lot! Anny