JSP version of a JavaScript

Hello again,
I have a javascript that I need to run as a JSP function. I can not use JavaScript unfortunately.
var width = screen.width
var height = screen.height
if (screen.width < 640)
{parent.location.href='http://www.prestonvalet.mobi'}
if (screen.width > 639)
{parent.location.href='http://www.prestonmotor.com'}
How would I do that in Java?
PS I am also looking to hire per diem Java programmers so PM or IM me if you are interested.
MSN: [email protected]
ICQ: 173037317
AIM: piercedink
Yahoo: happyman0313

per diem is latin for per day and is a generally accepted term for project work. So instead of getting paid by the hour you get paid by the project.
I would gladly do this anyone you guys suggest. Again I am not a JAVA programmer so code snippets are very useful.
Basically I want to be able to determine if the device reading the website is a mobile device or not.
Now I did find some code to read screen resolution in java:
import java.applet.*;
import java.awt.*;
import java.net.*;
public class ScreenRes extends java.applet.Applet {
  public void start() {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    String file = null;
    URL url = null;
     if (screen.width > 640)
               { file = "httP://www.prestonmotor.com"; // 640x480
            break;
    try { url = new URL(getDocumentBase(), file); }
    catch ( MalformedURLException e) {
      url = null;
    if (url != null) {
      getAppletContext().showDocument(url);
  }But I do not know how to incorporate into JSP and perhaps, based on what you said, I can not.

Similar Messages

  • JSP response into a Javascript code

    Suppose I have a form that I submit, and its action is set to a JSP page that returns a series of elements <option>, for example:
        <option>2005</option>
        <option>2006</option>
    Is it possible to GET that JSP response, inside the JavaScript code?
    Or should I better state, inside the JSP code, to return ONLY the numbers and then I get it on the JavaScript and use the .add() funtion to add the item to a <select> ?
    How do I save that response inside the JavaScript?
    For example, I am trying with this Javascript function that handles the changes on a drop-down list:
      function clickedOnPType(lista)
      document.form1.action = "searchAvailableYears.jsp?pType=" + txtPType;}
      document.form1.submit();
    }...And I am getting, in return, a series of <option> with the correct data...
    Thanking you in advance,
    MMS

    Oh hello... in one of my 1000 searches I found that
    post days ago and I was already trying with your
    code, but I was getting several errors like
    "undefined is null or not an object" (in IE),
    "xmlhttp.responseXML has no properties" (in
    Firefox).... Well one thing i wanted to discuss here is is wat properties does in general a XmlHttpRequest Object contains
    checkout the below interface which gives a clear understanding of the Object member properties.
    interface XMLHttpRequest {
      attribute EventListener   onreadystatechange;
      readonly attribute unsigned short  readyState;
      void  open(in DOMString method, in DOMString url);
      void  open(in DOMString method, in DOMString url, in boolean async);
      void  open(in DOMString method, in DOMString url, in boolean async, in DOMString user);
      void  open(in DOMString method, in DOMString url, in boolean async, in DOMString user, in DOMString password);
      void  setRequestHeader(in DOMString header, in DOMString value);
      void  send();
      void  send(in DOMString data);
      void  send(in Document data);
      void  abort();
      DOMString  getAllResponseHeaders();
      DOMString  getResponseHeader(in DOMString header);
      readonly attribute DOMString  responseText;
      readonly attribute Document   responseXML;
      readonly attribute unsigned short  status;
      readonly attribute DOMString  statusText;
    };therefore as you can see XmlHttpRequest.reponseXML returns a Document Object which has below set of properties.
    http://www.w3schools.com/dom/dom_document.asp
    http://www.javascriptkit.com/domref/documentproperties.shtml
    and as said earlier one can send AJAX response in three ways
    1).Plain text(with comma seperated values maybe): Which we can collect using XmlHttpRequest.responseText 2).XML: @ client side XmlHttpRequest.reponseXML create a DOM Object using which one can parse it get values
    of attributes and values of different tags and then update the view accordingly.
    3).JSON(Javascript Object Notation): It is a bit complicated thing to discuss at this moment
    however it uses the first property(Plain text) and then
    uses set of libraries to parse and update the view.
    checkout below links to understand it
    http://www.ibm.com/developerworks/library/j-ajax2/
    http://oss.metaparadigm.com/jsonrpc/
    >  function handleOnChange(ddl)
    >
    var ddlIndex = ddl.selectedIndex;
    var ddlText = ddl[ddlIndex].text;
    var frmSelect = document.forms["form1"];
    var frmSelectElem = frmSelect.elements;
    if(ddl.name="pType")
         txtYear = "";
    txtDay = "";
              txtTime = "";
              unblock(document.form1.year);
              block(document.form1.day);
              block(document.form1.time1);
         laProxLista = frmSelectElem["year"];
    if (ddl.options[ddl.selectedIndex].text !=
    txtPType = ddl.options[ddl.selectedIndex].text;
    else if(ddl.name="year")
         txtDay="";
         txtTime="";
              unblock(document.form1.day);
              block(document.form1.time1);
    laProxLista = frmSelectElem["day"];
    f (ddl.options[lista.selectedIndex].text != "---")
    txtYear = ddl.options[lista.selectedIndex].text;
    else if(ddl.name="day")
    {          txtTime = "";
              unblock(document.form1.time1);
    laProxLista = frmSelectElem["time1"];
    (ddl.options[ddl.selectedIndex].text != "---")
    txtDay = ddl.options[ddl.selectedIndex].text;
    else //time1
    laProxLista = null;
    if (ddl.options[ddl.selectedIndex].text != "---")
    txtTime1 = ddl.options[ddl.selectedIndex].text;
    if ( txtPType != "---")
    xmlhttp = null
    // code for initializing XmlHttpRequest
    Object On Browsers like Mozilla, etc.
    if (window.XMLHttpRequest){ 
    xmlhttp = new XMLHttpRequest()
    // code for initializing XmlHttpRequest
    Object On Browsers like IE
    else if (window.ActiveXObject) { 
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp != null)
    if(ddl.name = "pType")
    // Setting the JSP/Servlet url to get
    XmlData
    url = "searchAvailableYears.jsp?pType="
    + txtPType;
                   else if(ddl.name = "year")
    url = "searchAvailableDOY.jsp?pType=" + txtPType
    PType + "&year=" + txtYear;
                   else(ddl.name = "day")
    url = "searchAvailableTimes.jsp?pType=" +
    e=" + txtPType + "&year=" + txtYear + "&day=" +
    txtDay;
    xmlhttp.onreadystatechange =
    handleHttpResponse;
    // Open the Request by passing Type of
    Request & CGI URL
    xmlhttp.open("GET",url,true);
    // Sending URL Encoded Data
    xmlhttp.send(null);
    else{
    // Only Broswers like IE 5.0,Mozilla & all other
    browser which support XML data Supports AJAX
    Technology
    // In the Below case it looks as if the
    browser is not compatiable
    alert("Your browser does not support
    XMLHTTP.")
    } //else
    } //if chosen
    //function
         //----------------------------Well as far as i can see i do not have any issues with it because your code looks
    preety much involved with your business logic but one thing i would like to reconfim
    here is the variable "xmlhttp" a global one.
    if no declare xmlhttp variable as a global variable.
    <script language="javascript">
    var xmlhttp;
    function handleOnChange(ddl){
    function verifyReadyState(obj){
    function handleHttpResponse() {
    </script>
    > function verifyReadyState(obj)
    if(obj.readyState == 4){
    if(obj.status == 200){
    if(obj.responseXML != null)
    return true;
    else
    return false;
    else{
    return false;
    } else return false;
    }I believe,this is preety much it.
    > function handleHttpResponse() [/b]
    if(verifyReadyState(xmlhttp) == true)
    //-----------HERE!! ---- I GET "UNDEFINED" IN THE
    DIALOG BOX
    //------- BELOW THE CODE LINE....---
    var response = xmlhttp.responseXML.responseText;
    alert(response);
    it is obvious that you would get Undefined here as responseText is not a property of Document Object or to be more specific to the Object what xmlhttp.responseXML returns.
    you might have to use that as alert(xmlhttp.responseText);
    and coming back to parsing the XML reponse you have got from the server we need to use
    var response = xmlhttp.responseXML.documentElement; property for it...
    and if you put as a alert message it has to give you an Output like"Object"
    alert(response);
    if that doesn't the browser version which you are using may not support XML properly.
    var response = xmlhttp.responseXML.documentElement;
    removeItems(laProxLista);
    var x = response.getElementsByTagName("option")
      var val
      var tex
      var newOption
                  for(var i = 0;i < x.length; i++){
                     newOption = document.createElement("OPTION")
                     var er
                     // Checking for the tag which holds the value of the Drop-Down combo element
                     val = x.getElementsByTagName("value")
    try{
    // Assigning the value to a Drop-Down Set Element
    newOption.value = val[0].firstChild.data
    } catch(er){
    // Checking for the tag which holds the Text of the Drop-Down combo element
    tex = x[i].getElementsByTagName("text")
    try{
    // Assigning the Text to a Drop-Down Set Element
    newOption.text = tex[0].firstChild.data
    } catch(er){
    // Adding the Set Element to the Drop-Down
    laProxList.add(newOption);
    here i'm assuming that i'm sending a xml reponse of format something below.
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <drop-down>
       <option>
            <value>1</value>
            <text>label1</text>
       </option>
       <option>
            <value>2</value>
            <text>label2</text>
       </option>
       <option>
            <value>3</value>
            <text>label3</text>
       </option>
    </drop-down>and i'm trying to update both option's value and label which would be something like
    <select >
    <option value="1">label1</option>
    <option value="2">label2</option>
    <option value="3">label3</option>
    <option value="4">label4</option>
    </select>else where if you are interested in getting a format like the one below
    <select >
    <option>label1</option>
    <option>label2</option>
    <option>label3</option>
    <option>label4</option>
    </select> try the below snippet
    var response = xmlhttp.responseXML.getElementsByTagName("text");
    var length = response.length;
    var newOption
    for(var i =0 ; i < length;i++){
       newOption = this.document.createElement("OPTION");
       newOption.text = response.childNodes[0].nodeValue;
    // or newOption.text = response[i].firstChild.data
    laProxList.add(newOption);
    Another thing...
    I have tried to set the content type inside the JSP
    to
    response.setContentType("text/html");
    AND to
    response.setContentType("text/xml");
    but none of the above is getting me results......use of response.setContentType("text/xml"); is more appropriate here.. as you are outputting XML or a plain text here...
    make sure you set the reponse headers in the below fashoin while outputting the results....
    response.setContentType("text/xml");
    response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 1);
    response.setDateHeader("max-age", 0); and if you are serious about implementing AJAX i would advice you start learn basics of XmlHttpRequest Object and more about DOM parsing is being implemented using javascript.
    http://www.w3.org/TR/XMLHttpRequest/#xmlhttprequest0
    http://www.jibbering.com/2002/4/httprequest.html
    http://java.sun.com/developer/technicalArticles/J2EE/AJAX/
    http://developer.apple.com/internet/webcontent/xmlhttpreq.html
    http://www.javascriptkit.com/domref/documentproperties.shtml
    and then go about trying different means of achieving them using simpler and cool frameworks
    like DWR,dojo,Prototype,GWT,Jmaki,Back Base 4 Struts,Back Base 4 JSF....etc and
    others frameworks like Tomahawk,Ajax4Jsf,ADF Faces,ICE FACES and many others which work with JSF.
    Please Refer
    http://swik.net/Java+Ajax?popular
    http://getahead.org/blog/joe/2006/09/27/most_popular_java_ajax_frameworks.html
    Hope that might help :)
    and finally an advice before implementing anything specfic API which may be related to any technologies (JAVA,javascript,VB,C++...) always refer to API documentation first which always gives you an Idea of implementing it.
    Implementing bad examples posted by people(even me for that matter) directly doesn't make much sense as that would always lands you in trouble.
    and especially when it is more specific to XmlHttpRequest always make habit of refering
    specific Browser site to know more about why specific Object or its property it not working 4i
    IE 6+: http://msdn2.microsoft.com/en-us/library/ms535874.aspx
    MOZILLA: http://developer.mozilla.org/en/docs/XMLHttpRequest
    Safari: http://developer.apple.com/internet/webcontent/xmlhttpreq.html
    Opera 9+: http://www.opera.com/docs/specs/opera9/xhr/
    Hope there are no hard issues on this...
    REGARDS,
    RaHuL

  • How to get values from a table(in jsp) for validation using javascript.

    hi,
    this is praveen,pls tell me the procedure to get values from a table(in jsp) for validation using javascript.
    thank you in advance.

    Yes i did try the same ..
    BEGIN
    select PROD_tYPE into :P185_OFF_CITY from
    magcrm_setup where atype = 'CITY' ;
    :p185_OFF_CITY := 'XXX';
    insert into mtest values ('inside foolter');
    END;
    When i checked the mtest table it shos me the row inserted...
    inside foolter .. Now this means everything did get execute properly
    But still the vallue of off_city is null or emtpy...
    i check the filed and still its empty..
    while mtest had those records..seems like some process is cleaining the values...but cant see such process...
    a bit confused..here..I tried on Load after footer...
    tried chaning the squence number of process ..but still it doesnt help
    some how the session variables gets changed...and it is changed to empty
    Edited by: pauljohny on Jan 3, 2012 2:01 AM
    Edited by: pauljohny on Jan 3, 2012 2:03 AM

  • How can I access JSP variables from a JavaScript function in a JSP page?

    Respected sir
    How can I access JSP variables from a JavaScript function in a JSP page?
    Thanx

    You may be get some help from the code below.
    <%
        String str="str";
    %>
    <script>
        function accessVar(){
           var varStr='<%=str%>';
           alert(varStr);// here will diplay 'str'
    </script>

  • Accessing JSP variables in Included Javascript

    Hey All,
    I want to hide my javascript to be viewed on the client browser.
    I know we can do that with the javascript include ,But i am using JSP variables in
    Included javascript.I can't access those variables any more.
    Does anybody know any workarround.
    Thanx
    Vijay

    Hi Vijay,
    I am also facing the same problem of hiding javascript in the client browser. My javascript variables are getting initialised on the fly using JSP. Since JSP is compiled on the server side, one can't compile .js file on the client side.
    What u can do is to divide your page into frames with
    <frameset rows="100%,0%">. Now put your form hidden fields or the .js file in frame 2 which is not visible to the user and then assign your jsp variables in the frame2 html/jsp page. Now access your variables from frame2 in frame1 using
    var i = parent.frames[1].document.forms[0].elements[0].value
    Assuming that there is 1 form and 1 hidden field in frame2 html/jsp page.
    I hope u get the logic rite....
    I had done it for application but problem is that our users are real MORONS and they keep doing ctrl+F5 which takes them to the Indexpage.
    If you get some other solution then please mail it to my email address
    [email protected]
    Regards
    Vimlesh

  • Can anyone suggest how to check  JSP version

    can anyone suggest how to check JSP version

    How to check JSP version of what? Your server?
    Handy little JSP page to do just that:
    Working with server: <%= application.getServerInfo() %><br>
    Servlet Specification: <%= application.getMajorVersion() %>.<%= application.getMinorVersion() %> <br>
    JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %><br>
    Sessionid : <%= session.getId() %><br>

  • Calling a jsp:useBean method in Javascript

    Hi,
    I want to call a jsp:useBean method in Javascript. Like:-
    <jsp:useBean id="StringEscapeUtils" class="org.apache.commons.lang.StringEscapeUtils" scope="application" />
    <script>
    var accountNumber = '<c:out value="${ACCOUNT_NUMBER}" />';
    var accountNumberWithSingleQuote = "<%=StringEscapeUtils.escapeJavascriptString('<%=accountNumber%>')%>"; // not working
    alert(accountNumberWithSingleQuote );
    </script>
    Here var accountNumberWithSingleQuote = "<%=StringEscapeUtils.escapeJavascriptString('<%=accountNumber%>')%>"; // not working
    Here how to add the parameter accountNumber in the escapeJavascriptString() method?
    Is it possible can we do it without scriptlet in JS? Pls. let me know your opinion.
    thanks.

    797836 wrote:
    Here var accountNumberWithSingleQuote = "<%=StringEscapeUtils.escapeJavascriptString('<%=accountNumber%>')%>"; // not working
    The above line will not work, because you are using scriptlet within a scriptlet.
    accountNumber is a javascript variable, so there is no way to use javascript variable in scriptlets.
    Here how to add the parameter accountNumber in the escapeJavascriptString() method?
    Is it possible can we do it without scriptlet in JS? Pls. let me know your opinion.
    You are assigning a value to accountNumber variable using springs variable, i.e ACCOUNT_NUMBER.
    So why don't you directly use the ACCOUNT_NUMBER variable which is a java scriptlet.
    Below is the url will guide you for the same:
    http://www.avajava.com/tutorials/lessons/how-do-i-access-a-jstl-variable-in-a-scriptlet.html

  • JSP 2.0 and JavaScript

    Is it possible to use JavaScript with version 2.0 JSPs?

    Sure is... but, of course, that is simply because JavaScript has nothing to do with Java or JSP.
    JavaScript runs on the client side, in the browser. The JSP page will just output HTML and if you include JavaScript in that HTML output, or link to a JS file or whatever, that's fine. The server doesn't care.

  • How to put a jsp variable into a javascript function?

    Please read the following coding. I want to pass the variable ans from jsp to the function check_answer() of javascript. ans is a string got from database. But I cannot put the variable ans into the Javascript function. Can anyone help?
    <script language="Javascript">
    function check_answer() {
    if (testing.result.value==ans ){
    window.alert("You have got 10 marks.");
    </script>
    <body>
    <form name="testing"...>
    <%
    ResultSet rs = stmt.executeQuery("select * from level where...");
    while(rs.next())
    out.println("<tr>");
    out.println("<td>" + rs.getString("question") + "</td>");
    ans = rs.getString("answer");
    out.println("</tr>");
    out.println("<input type='text' name='result'>);
    out.println("<input type='button' value='Enter' onclick='check_answer()'>");
    %>

    The following should be able to pass ans.
    <script language="Javascript">
    function check_answer(ans) {
    if (testing.result.value==ans ){
    window.alert("You have got 10 marks.");
    </script>
    <body>
    <form name="testing"...>
    <%
    ResultSet rs = stmt.executeQuery("select * from level where...");
    while(rs.next())
    out.println("<tr>");
    out.println("<td>" + rs.getString("question") + "</td>");
    ans = rs.getString("answer");
    out.println("</tr>");
    out.println("<input type='text' name='result'>);
    out.println("<input type='button' value='Enter' onclick='check_answer('<%= ans%>')'>");
    %>jag

  • JSP unable to load javascript

    I have a JSP page that is using a tag library from DotJ software. With the tag library there is an accompanying javascript library that handles the client side of the form. The screen runs okay on my laptop from within JDeveloper and from JDeveloper on the server that we are to deploy to.
    The problem occurs when I try to run the page from 10g application server.
    Generally, when I test the page its usually as an address of the form:-
    xxx.xxx.xxx.xxx/UPDORA/Screen.jsp
    When the page loads everything is there (logos, buttons, grid data etc.) but an error is displayed stating that the javascript file couldn't be loaded. The alert displays the URL that it is trying to load the javascript from - this seems to be different to the URL that I run the page from:
    http://<machine name here>:81/UPDORA/dotj/dotj_2_0.js
    I'm guessing that the inclusion of the port number is causing the problem ? The dotj directory is in the same place as Screen.jsp so I would assume if it can find one it can find another - but it isn't. I'm not sure if the problem is with the application server or the tag library that is trying to load the javascript file - but the screen runs okay from JDeveloper.
    Does anyone have any idea what the problem may be ?

    Hi,
    I do not know what is the cause of your problem. However, it should be easy to identity the root cause. Here are some basic suggestions:
    1. Since you can access http://something/here/Screen.jsp, try accessing http://samething/here/dotj/dotj_2_0.js from your browser directly just to make sure it is there.
    2. check page source received by your browser to see the address of your javascript.
    3. check .java file generated out of your jsp file by jdeveloper, which should be inside the directory for your jdeveloper project. Also check the .java file generated by your application server, which is in j2ee/home/application-deployments/yourApp/yourWebApp/persistence/_page. Find what is the difference that causes, I assume, different urls for your javascript.

  • Included JSP files not seeing JavaScript in main JSP file

    Hi All,
    I have a JSP page that defines a JavaScript block in it's HEAD block and then includes multiple JSP pages in it's BODY block. Calling a JavaScript function from any of the included JSP pages is met with the following JavaScript error:
    JavaScript Error: [unknown origin]:
    showBatchDetail is not defined.
    I'm not sure what is wrong here since the JSP is generating on the server side and everything is fine by the time it gets to the client side. The entire client side file should be seeing the JavaScript block that was included in the main file.
    Any help here would be much appreciated.
    Steph.
    Some barebones code appears below:
    Main.jsp
    <HTML>
    <HEAD>
    <TITLE>UNIT INFO</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    function showBatchDetail(batchKey)
    var url = "/pditools/html/SfmReports/ShowBatchDetail.jsp"
    + "?batchKey=" + batchKey;
    document.location = url;
    </SCRIPT>
    </HEAD>
    <BODY>
    <%@include file="ShowBatchSummary.jsp"%>
    <%@include file="ShowUnitDefects.jsp"%>
    <%@include file="ShowUnitHistory.jsp"%>
    </BODY>
    </HTML>
    ShowBatchSummary.jsp
    <TABLE>
    <TR>
    <TD>
    BATCH SUMMARY
    <A TARGET="_blank" HREF="JavaScript:showBatchDetail(1000);">(Batch Detail)</A>
    </TD>
    </TR>
    <TR>
    Show some data ...
    </TR>
    </TABLE>

    The problem is not about include but about link use
    ----ShowBatchSummary.jsp----
    <TABLE>
    <TR>
    <TD>
    BATCH SUMMARY
    <A TARGET="_blank" HREF="#" onclick="JavaScript:showBatchDetail(1000);">(Batch Detail)</A>
    </TD>
    </TR>
    <TR>
    Show some data ...
    </TR>
    </TABLE>
    -------end of ShowBatchSummary.jsp--------

  • Parsing JSP values on to javascript functions

    HI
    Is it possible for Javascript functions to accept JSP variables?
    For instance:
    <script language="Javascript">
    function selectEdit(fileID) {
       document.forms[0].recordID.value = fileID;
       document.forms[0].submit();
         </script> and a button calls the method like this:
       <input type="submit" name="Submit" value="View" onClick="selectEdit('<%= Record %>'")> I tried but was unsuccessful, can someone help?
    Thanks
    Eugene

    Lets say you use your JSP to generate a set of links
    page1.jsp:
    <form target="targetPage.jsp">
    <input type="hidden name="recordId");
    <% for (int record=0; record<10; record++){  %>
      <input type="submit" name="Submit" value="View" onClick="selectEdit('<%= record %>')">
    <%  }  %>
    </form>This JSP code runs, and generates the following
    <form target="targetPage.jsp">
    <input type="hidden name="recordId");
    <input type="submit" name="Submit" value="View" onClick="selectEdit('0')">
    <input type="submit" name="Submit" value="View" onClick="selectEdit('1')">
    <input type="submit" name="Submit" value="View" onClick="selectEdit('2')">
    <input type="submit" name="Submit" value="View" onClick="selectEdit('3')">
    <input type="submit" name="Submit" value="View" onClick="selectEdit('4')">
    <input type="submit" name="Submit" value="View" onClick="selectEdit('5')">
    <input type="submit" name="Submit" value="View" onClick="selectEdit('6')">
    <input type="submit" name="Submit" value="View" onClick="selectEdit('7')">
    <input type="submit" name="Submit" value="View" onClick="selectEdit('8')">
    <input type="submit" name="Submit" value="View" onClick="selectEdit('9')">
    </form>This gets sent to your browser on displayed on screen
    When you click on the appropriate button, it calls your function selectEdit, which sets the value of the hidden field according to which button you pushed.
    It then submits the form, to targetPage.jsp
    targetPage.jsp retreives the value using request.getParameter("recordId");
    which is the name of the hidden field being submitted.
    JSP reacts to form submissions, and produces an HTML page.
    The HTML page can then run java script
    JSP gets run again when you submit the form.
    Hope this helps,
    evnafets

  • Jsp session variable in javascript

    hi,
    i want use a jsp session variable inside a javascript code, for this i am using the following function,
    function checkList()
    <% String ecode1=(String)session.getAttribute("e_numb"); %>
    var code=<%=ecode1%>
    alert (code)
    this is showing an error can any one please help me,
    thanks
    saurabh

    You have ',%String ecode1' within the javascript. JSP will not recognize 'String' as a java class unless you import the String class. Something like <%@ page import = "java.util.* " %> Incorrect. String is part of java.lang, which is always imported into a java class.
    Most probably what is missing in the javascript is
    - missing quotes ? Not sure if this value is meant to be interpreted as a number or not.
    - missing semicolon
    function checkList()
    <% String ecode1=(String)session.getAttribute("e_numb"); %>
    var code="<%=ecode1%>";
    alert (code);
    }Lets assume that the value of e_numb is "42"
    after running this as a jsp, it should produce the following on the resulting html page. You can see it by viewing the source.
    function checkList()
    var code="42";
    alert (code);
    }Check that to see it has produced valid javascript
    Cheers,
    evnafets

  • How to find the servlet, jsp version available for SunOne 7 webserver

    hi ,
    I am looking for a command that can say the version of servlet, JSP container in Sun One7 webserver.
    as in weblogic we can do by command
    java weblogic.version -verbose
    is similar type of command is available for SunOne 7 web server

    Hi,
    Ask BASIS person to check the JMS driver which is installed on XI through visual admin.
    Thnx
    Chirag

  • Passing vars...JSP resolves faster than javascript - is there a workaround?

    HI
    The variable/value ("fieldA") that I want to pass from "frame1.jsp" to "frame2.jsp is actually a variable defined javascript function "getTest()" in "frame1.jsp".
    I want to pass "fieldA" from "frame1.jsp" to "frame2.jsp"..
    "frame2" is initially "blank.html. In the "getTest()" function I use (parent.frames[2].location = "frame2.jsp";) to create frame2.jsp inside of "frame2"
    I generat a "post" request (from "frame1.jsp") assigning "fieldA" to a hidden form field ("fldA") in "frame2", and then display the value of "fldA" using "<%= request.getParameter("fldA") %>"...
    But the value of hidden form field - "fldA" - is initially "null" because when "frame2.jsp" page is creatd, the JSP scriplets resolve before the javascript "getData" function can resolve. (if I click to post frame2.jsp again, the value shows - but, that's just because the frame2.jsp now exists.)
    Is there a work around?.... Or, do I need to have "frame1.jsp" call a servlet to pass "fieldA" ????
    Appreciate ANY help on this!!!!
    (NOTE -- actually, my real world need will be to assign the value to a Custom Tag parameter, rather than simply display - and that is why I need to get this to work!)
    THE WORKING CODE IS BELOW. . . (AGAIN ANY HELP IS APPRECIATED!)
    *****frame0.html*****
    <%@ page language="java" import="java.io.*, java.util.*" errorPage="error.jsp" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>frame0</TITLE>
    </HEAD>
    <FRAMESET FRAMEBORDER="2" ROWS="20%,80%">
    <FRAME SRC="frame0.html" NAME="frame0">
    <FRAMESET FRAMEBORDER="2" COLS="20%,80%">
    <FRAME SRC=frame1.jsp?fieldX=<%= session.getParameter("fieldX") %> NAME="frame1">
    <FRAME SRC=frame2.jsp?fieldX=<%= session.getParameter("fieldX") %> NAME="frame2">
    </FRAMESET>
    </FRAMESET>
    </HTML>
    *****frame1.jsp*****
    <%@ page language="java" import="java.io.*, java.util.*" errorPage="error.jsp" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
         <head><title>frame1</title>
         <link rel="stylesheet" type="text/css" href="./standard.css">
              <script LANGUAGE="JavaScript">
                   parent.frames[2].location = "blank.html";
                   function getTest()
                        var fieldA = "HO THERE!!!"
                        <%
                             session.putValue("fieldB", "HEY THERE!!!");
                        %>
                        parent.frames[2].location = "frame2.jsp";
                        parent.frames[2].getData(fieldA);
                        return;
    </script>
         </head>
         <body bgcolor="#FFFFFF" text="#000000">
              <p>
              <h2>
              In frame1.jsp, the value in fieldA is: <%= session.getAttribute("fieldA") %>
              <h2>
              In frame1.jsp, the value in fieldB is: <%= session.getAttribute("fieldB") %>
              <p>
              <form name="reportRange">
                   <center>
                        <fieldset style="padding: 0.5em" name="customer_box">
                        <table cellpadding="0" cellspacing="0" border="0">
                             <tr class="drophead">
                                  <td valign="top" height="0" ><span class="drophead">
                                       test submit
                                  </td>
                             </tr>
                        </table>
                        </fieldset>
                   </center>
              </form>
         </body>
    </html>
    *****frame2.html*****
    <%@ page language="java" import="java.io.*, java.util.*" errorPage="error.jsp" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
         <head>
         <title>frame2</title>
              <script LANGUAGE="JavaScript">
                   function getData(fieldA)
                   document.pageData.fldA.value = fieldA;
                        document.pageData.submit();
              </script>
         </head>
         <body>
              <p>
              <h2>
              In frame2.jsp, the value of fieldA: <%= request.getParameter("fldA") %>
         <h2>
              In frame2.jsp, the value of fieldB: <%= session.getValue("fieldB") %>
              <p>
              <div id="HiddenForm">
                   <form name="pageData" method="post" action="frame2.jsp" target="_self">
                        <input type="hidden" name="fldA" value="empty">
                   </form>
              </div>
         </body>
    </html>
    *****blank.html*****
    <html>
    <head>
    <title>blank page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="globalview.css" type="text/css">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    </body>
    </html>
    *****error.jsp*****
    <%-- error.jsp --%>
    <%@ page language="java" isErrorPage="true"%>
    <html>
    <head>
         <title>error page</title>
    </head>
    <body>
    <h2>Error Encountered: </h2>
    <%= exception.toString() %><BR>
    <br>
    details...<%= exception.getMessage() %>
    </body>
    </html>

    So where to start...
    1) session does not have a method "getParameter()" (frame0.jsp) so I don't know how you can get this to work.
    2) When you call "javascript:getTest()" the scriptlet is not run again. It's serverside so it is execute on the server then any return data is placed where you have the scriptlet.
    3) The scriptlets in "frame0.html" will not work as the page is declared as html.
    4) Once again jsp scriptlets (including TagLibraries) are server side components. Any values passed to them should be via a request or session setting on the server side.
    For example:
    Say we have a tag "myWorkingTag" that outputs the value we assign to "valToUse" on the page.
    original jsp document (page.jsp):
    <%@ taglib uri="mytags" prefix="mine" %>
    <html>
    <body>
    <mine:myWorkingTag valToUse="xyz"/>
    </body>
    </html>
    The web browser view of page.jsp:
    <html>
    <body>
    xyz
    </body>
    </html>
    You can assign the "valToUse" attribute using <%="xyz"%> (or session.getAttribute() or request.getParameter()) on the server side but ultimately you need to send the value to the server and recompile the page.
    I've made some changes to your code (in bold) which is a minor fix but not a solution to your overall objective.
    ***** frame0.jsp *****
    <HTML>
    <HEAD>
    <TITLE>frame0</TITLE>
    </HEAD>
    <FRAMESET ROWS="20%,80%">
    <FRAME SRC="frame0.jsp" NAME="frame0">
    <FRAMESET COLS="20%,80%">
    <FRAME SRC=tFrame1.jsp?fieldX=<%= request.getParameter("fieldX") %> NAME="frame1">
    <FRAME SRC=tFrame2.jsp?fieldX=<%= request.getParameter("fieldX") %> NAME="frame2">
    </FRAMESET>
    </FRAMESET>
    </HTML>
    ***** frame1.jsp *****
    <%@ page language="java" import="java.io.*, java.util.*" errorPage="error.jsp" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head><title>frame1</title>
    <link rel="stylesheet" type="text/css" href="./standard.css">
    <script LANGUAGE="JavaScript">
    //parent.frames[2].location = "blank.html";
    function getTest()
    var fieldA = "HO THERE!!!"
    <%session.setAttribute("fieldB", "HEY THERE!!!");%>
    parent.frames[2].location = "frame2.jsp";
    parent.frames[2].getData(fieldA);
    return;
    </script>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <p>
    <h2>
    In frame1.jsp, the value in fieldA is: <%= session.getAttribute("fieldA") %>
    <h2>
    In frame1.jsp, the value in fieldB is: <%= session.getAttribute("fieldB") %>
    <p>
    <form name="reportRange">
    <center>
    <fieldset style="padding: 0.5em" name="customer_box">
    <table cellpadding="0" cellspacing="0" border="0">
    <tr class="drophead">
    <td valign="top" height="0" ><span class="drophead">
    test submit
    </td>
    </tr>
    </table>
    </fieldset>
    </center>
    </form>
    </body>
    </html>
    *****frame2.jsp*****
    <%@ page language="java" import="java.io.*, java.util.*" errorPage="error.jsp" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>frame2</title>
    <script LANGUAGE="JavaScript">
    function getData(fieldA)
    document.pageData.fldA.value = fieldA;
    document.pageData.submit();
    </script>
    </head>
    <body>
    <%if(request.getParameter("fldA")!=null){
    //this section doesn't make sense, your using the same value twice!?!%>
    <p>
    <h2>
    In frame2.jsp, the value of fieldA: <%= request.getParameter("fldA")
    %>
    <h2>
    In frame2.jsp, the value of fieldB: <%= session.getAttribute("fieldB") %>
    <p>
    <%}%>
    <div id="HiddenForm">
    <form name="pageData" method="post" action="frame2.jsp" target="_self">
    <input type="hidden" name="fldA" value="empty">
    </form>
    </div>
    </body>
    </html>
    ***** blank.html (obsolete) *****
    ***** error.jsp unchanged *****
    What you should be aiming for is either:
    A) Using the above code, send all your required parameters to the form in frame2.jsp and use these parameters to configure the page. As you can see I added an "if(request.getParameter("fldA")!=null)" block to prevent any code from being execute until you send the data.
    B) In frame1.jsp, submit it to itself with all the parameters you need and add the objects to the session. When frame1.jsp returns the page to the browser, get it to call a javascript function (<body onload='...'>") to reload frame2.jsp and collect the objects/variables from the session.
    Just remember Javascript and Java in JSP's don't exist in the same "world" so to speak. They have to cross a bridge to communicate, the bridge being the action of the form.
    Cheers,
    Anthony

Maybe you are looking for

  • What is the best way to add a large number dynamic VI's in the application builder?

    Is there a way to add all the VI's in a directory tree or library file as "Dynamic VI's" in the application builder (7.1 on Windows XP SP2)? Thanks, Mark Moss

  • Help needed with 3rd party software and Windows XP on MacBook

    My Brother embroidery software has stopped working on the XP side of my MacBook. After all kinds of uninstalling and installing with support from Brother, they decided the problem is not the software and I should "contact my computer company." Since

  • Customer Spl GL 'O' not able to post

    Hi Guru, We are tring to post the transaction with Spl GL 'O" for customer entry..,,but while we are entring profit center in the transaction the system is giving  "PO value is lesser than Order Value" but there is no relation with this error message

  • Error type 102

    I have an i book a friend gave me but when i put it on it says error type 102 temporary turn off extensions ,restart and hold down the shift key but is not doing nothing after i hold the key and shut it down .not even the cursor comes up . Is somebod

  • Getting the most out for a user that is not exactly savvy

    My apologies if I have broached this topic somewhat before. I bought my first computer last fall and was not that familiar with Windows based machines at the time. Currently, I just surf the internet and check my email in yahoo. I'd like to get more