cancel
Showing results for 
Search instead for 
Did you mean: 

Read parameter from URL in Java

junmei
Participant
0 Kudos

See below...

Accepted Solutions (0)

Answers (3)

Answers (3)

junmei
Participant
0 Kudos

See above

praveenkumar_kadi
Active Contributor
0 Kudos

Hi,

Ideally if you have your NWDS installed, no need to import any java package.

try to check if the above code works fine for you..else you will have to do import jar

called "WDProtocolAdapter" and re-check.

Hope that helps

junmei
Participant
0 Kudos

I have NWDS installed but it's not a WebDynpro project so I need to import the JAR file. Problem is I can't find it... any idea were I have to look?

praveenkumar_kadi
Active Contributor
0 Kudos

Hi,

add the following jar file to the classpath of your NWDS project:

/usr/sap/<J2E>/<JC01>/j2ee/cluster/server0/bin/services/webdynpro/webdynprolib/_webdynpro_services.jar

Just a hint. Next time you are missing a class use a tool (WinRar, JarFinder, etc.) to find out in which jar file your missing class is stored in.

Hope that helps..reward points if it so.

junmei
Participant
0 Kudos

Thanks again. I found the JAR file and now I have the following:

package z.mycompany;
import com.sap.tc.webdynpro.services.sal.adapter.api.WDWebContextAdapter;
import com.sapportals.portal.prt.component.*;

public class LogonRedirect extends AbstractPortalComponent
{
    public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
    {
		String URLParams = WDWebContextAdapter.getWebContextAdapter().getRequestParameter("name");
		response.write("Resulting URL name parameter: "+URLParams);
    }
}

I packed it as a PAR file and uploaded it but when I make an iView out of this it fails (get the red error text that something went wrong). It works when I only write a small text, it doesn't when I try this, any idea?

I'll reward points, once I have some result.

praveenkumar_kadi
Active Contributor
0 Kudos

Hi,

As for my knowledge goes.I think this seems some problem with the browser.

version and all.

Check you have IE 6.0+ and HTTP1.1 and above

Apart from this I am not sure how I can assist you in this regard.

Regards

Praveen

junmei
Participant
0 Kudos

Praveen kumar Kadi, thanks for your help. It doesn't work the way you descibed but never the less you pointed me in the right direction!

This seems to work better (for futher reference):

package z.mycompany;
import com.sapportals.portal.prt.component.*;
public class LogonRedirect extends AbstractPortalComponent
{
    public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
    {
		String param = request.getParameter("someparam");
		response.write("Resulting URL name parameter: "+param);
		
    }
}

And then make sure both the page and iView are set to embedded isolation method.

praveenkumar_kadi
Active Contributor
0 Kudos

Hi

To get parameter value, I think you can use following line

String URLParams = WDWebContextAdapter.getWebContextAdapter().getRequestParameter("name");

In addition you can also look at

Set parameters to URL and get the parameter value.

to set parameters:

String deployableObject = wdComponentAPI.getDeployableObjectPart().getDeployableObjectName();

WDDeployableObjectPart dpObj = WDDeployableObject.getDeployableObjectPart(deployableObject,"deployableObjectPart",WDDeployableObjectPartType.APPLICATION);

Map parameters = new HashMap();

parameters.put("name","Mack");

parameters.put("age","23");

String url = WDURLGenerator.getApplicationURL(dpObj,parameters);

================

You can also refer another way of doing.

Yet another way of.....

Hope that helps

junmei
Participant
0 Kudos

Thanks Praveen kumar Kadi. I'm new to this but as far as I can tell this WDWebContextAdapter is a WebDynpro component, which Java package do I have to import in my Netweaver developer studio Java project to use this? Do I need a WebDynpro project or can I get away with Java?