• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to read multiple parameters from jsp url

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am just a newbie to jsp and I have a requirement in which I will get a url with multiple parameters specified in it.

http://boprod.xyz.com/AdminTools/PkgSlp_Deep.jsp?&n1=1836087&n2=1&n3=NET23

Inside the jsp page I have another link to a crystal report and I need to read these parameters in a variable and pass it to that crystal report url

http://boprod.xyx.com/BOE/OpenDocument/opendoc/openDocument.jsp?sIDType=CUID&iDocID=AUdInRsZf4pIsLT0vsPZw7c&lsSOrder%20Number%3A=&n1&lsSRequest%20Number%3A=&n2&lsSContract%20Number%3A=&n3&&token=" + defaultToken.


Would you please able to help with the code I should be follow ?

Thanks,
Deep
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a JSP, the param implicit variable gives you access to the parameters.

So: ${param.n1}, ${param.n2}, and so on.

(Surely you can come up with better parameter names than n1 and n2?)
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I highly recommend that newcomers to JSP read the following articles:
  • The Secret Life of JSPs
  • The Front Man

  •  
    Deepcp Pandey
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks. Will be update the parameters name with something meaningful once I get this working. I tried this but doesn't seems to work

    <%@ page import="com.crystaldecisions.sdk.exception.SDKException" %>
    <%@ page import="com.crystaldecisions.sdk.framework.CrystalEnterprise" %>
    <%@ page import="com.crystaldecisions.sdk.framework.IEnterpriseSession" %>
    <%@ page import="com.crystaldecisions.sdk.framework.ISessionMgr" %>
    <%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoStore" %>
    <%@ page import="com.crystaldecisions.sdk.occa.security.ILogonTokenMgr"%>
    <%


    try
    {


    String systemName = "Server:6400";
    String userName = "Administrator";
    String password = "BOass23in";
    String authType = "secEnterprise";

    IEnterpriseSession enterpriseSession=null;
    ISessionMgr enterpriseSessionMgr = CrystalEnterprise.getSessionMgr();
    enterpriseSession = enterpriseSessionMgr.logon(userName, password, systemName, authType);
    ILogonTokenMgr logonTokenMgr = enterpriseSession.getLogonTokenMgr();

    String defaultToken = logonTokenMgr.createWCAToken("",10,1);

    response.sendRedirect("http://boprod.xx.com/BOE/OpenDocument/opendoc/openDocument.jsp?sIDType=CUID&iDocID=AUdInRsZf4pIsLT0vsPZw7c&lsSOrder%20Number%3A=${param.n1}&lsSRequest%20Number%3A=${param.n1}&lsSContract

    %20Number%3A=${param.n1}&&token=" + defaultToken);

    out.println(defaultToken);

    }
    catch(Exception e)
    {
    out.println(e);
    }

    %>
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You should not be putting Java code into your JSP. That is an outdated and obsolete practice from 13 years ago when JSP2 was introduced. 13 years!

    You should first be learning how to write modern JSP using the EL (Expression Language) and JSTL (JSP Standard Tag Library).
     
    Deepcp Pandey
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for nothing.
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    So you feel that using technology that is over 13 years out of date is appropriate? And that advice to help bring you up to modern standards is not helpful?

    Would you expect to be able to compete in the world as a carpenter if all you knew how to use were tools from the 1800s?

    Seriously, you need to modernize your approach and the advice I gave is to help you, not me. I don't gain anything from you learning skills that will actually help you.

    You are, of course, free to follow your own path.
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    If you have questions on how to structure the web app appropriately, please see the second of the articles I pointed you to. Generally Java code should be in a controller rather than a JSP. Beans, filters, EL functions, custom tags, and the like are also likely places for Java code.

    In that Java code, you would not use the EL (which is for JSPs) to fetch parameters, but the handful of methods on the request instance to fetch parameters such as getParameter() and getParameterValues().
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic