is there a way to access URL parameters in a Jetspeed2 Portlet/Portal?
like: www.bla.com/portal/page.psml?param=12345
I can only find some tools for liferay (PortalUtil.java) to access the httpservletrequest, but as far as i know there is no such thing for jetspeed?
I thought the public render parameters can be used for such thing, but i'm a little confused here? Didn't anyone had this problem before?
thanks in advance :)
found the answer:
Until version 2.1, Jetspeed merged portal request parameters with portlet specific
parameters, effectively allowing "shared" parameters.
This is not compliant with the JSR-168 PLT.11, so by default this is now disabled.
By setting merge.portal.parameters.with.portlet.parameters=true this feature can
be "restored".
In the situation of portal and portlet parameters with the same name, by default
the portlet parameters will be provided first in the values array, but this too
can be overridden by setting merge.portal.parameters.before.portlet.parameters=true
Setting both these properties to true will deliver the "old" pre-2.1 behavior.
Note: for individual portlets, these global settings can be overridden by setting these properties as metadata in jetspeed-portlet.xml
merge.portal.parameters.with.portlet.parameters=false
merge.portal.parameters.before.portlet.parameters=false
To use public render parameters from the 2.0 spec
Don't know if it works for jetspeed, but you can try getting the httprequest like this:
HttpServletRequest httpRequest = (HttpServletRequest) request.getAttribute("javax.servlet.request");
Then find the query string in a header like this:
String referer = httpRequest.getHeader("referer");
You'll then have the full page referer so you can parse the query string.
Related
Is there a way to read url as parameters?
for example url could be:
downloadSomething.com/data/json/something
And the method:
[HttpGet]
public async Task<Data> Data(string type, string otherParameter)
{
...
I know it's not a good practice.. I just want to know if is it possible.
Thx for help :)
I'm not sure exactly what you're asking here. The way routing works by default would allow this particular example.
[HttpGet("data/{type}/{otherParameter}")]
If you're talking about actually taking part of the path as a param, you can use the catch-all param, but it must be last param in the route (as it will obviously swallow everything).
[HttpGet("data/{**stuff}")]
That would then set the param stuff with the full path: json/something.
Thanks in advance for reading my question.
Question: I want original url in my strut's interceptor.
E.g:
From the browser, suppose i called... http://www.fakedomain.com/mycode/test.html
But this url is a url without rewrite...
Actually, Struts framework rewrite this into http://www.fakedomain.com/CreateMyCode.action
So, sceanario is...
When i fired the url from the browser...
First, Strut's filter comes in a picture and it determines weather url rewrite is required or not. If it requires then
Again same strut's filter is called modifdies into another url.
Finally, strut's interceptor comes in a picture. But now when i tried to get url... i got modified url.
But i want the original url (which is not rewrite by struts...and which is actual called from the browser).
How can i get this?
My Try:
I have created one new filter... which comes before urlrewrite filter. And set some attribute like...
HttpServletRequest httpReq = (HttpServletRequest) request;
String uri = httpReq.getRequestURI();
httpReq.setAttribute("URLBeforeRewrite", uri);
But in interceptor when i tried to get the value like...
req.getAttribute("URLBeforeRewrite")
i got modified url.
now, how can i solve this???
I ve a question. I have a JSON string ready to send to an Struts2 action from a ajax javascript function. Action is called properly, but i dont know how to get the JSON parameter from its method.
Is any struts.xml action configuration that makes me able to put automatically the information in the object, just as ..attributeClass?
In a similar way that i send from the server to the jqGrid (a javascript object to make grids with data inside, just with struts configuration result type=json and the attributes of the object that i want to send as a JSON string to the client web)?
Or maybe the only way is forget the struts.xml configuration and "hard programming" HttpServletRequest parameter, that has JSON string?
Thank you!
Both the JSON plugin and REST plugin can do what you want. Which makes more sense to use depends on the application.
You could do the work manually, either by accessing the request directly (not recommended), or by manually parsing a string parameter.
I am trying to print a web page at the default printer on the web server. I found the holy grail and it works but prints the login page not the target page, which makes sense because the controller requires auth using the asp.net membership with stock setup. I found this writeup where it is mentioned that you can use the dom interfaces if using forms auth (think that's me) but I'm not sure how to do that. It sounds like that would let the browser hit the login page and post the username/password back to finally hit the target page? Any insight on the best way to proceed would be very helpful, I would not have imagined it would be this involved to print a page that is already rendered (although printing server side it does kinda make sense). Thanks!
Edit: This works: (apparently cookie is the one thing you cannot set in the browser.Navigate method call)
HttpCookie cookie = Request.Cookies[".ASPXAUTH"];
InternetSetCookie(htmlPath, ".ASPXAUTH", cookie.Value);
browser.Navigate(htmlPath);
while (browser.ReadyState != WebBrowserReadyState.Complete)
Application.DoEvents();
dynamic ie = browser.ActiveXInstance;
ie.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, PRINT_WAITFORCOMPLETION);
and separately:
[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool InternetSetCookie(string lpszUrl, string lpszCookieName, string lpszCookieData);
This could be further improved using your code to get the forms cookie specifically instead of by name as my code.
The WebBrowser control has an overload method of the Navigate method which allows you to pass additional HTTP headers to the request. In the last argument you could pass the cookie header like this:
browser.Navigate(htmlPath, null, null, "Cookie: authCookie=value" + Environment.NewLine);
where obviously you need to replace authCookie with the name of the authentication cookie your web site expects and value with the value taken from the request cookie.
I have a ActionLink, that calls my public ActionResult, and I would like it to return back to the page that it was called from, but how?
There are a couple of tricks that you can use for this.
The simplest is ...
return Redirect(HttpContext.Request.UrlReferrer.AbsoluteUri);
AbsoluteUri may not give you the exact path you are looking for, but UrlReferrer should have the imformation you are looking for. Redirect returns a subclass of ActionResult so it is a valid return value.
Another idea is to base the redirect location off of stored values. This is useful when you are going to make multiple requests before you want to redirect, such as when you validate a form and show validation issues on the first response. Another situation will be when the referrer is not a local site. In either case, your referrer won't be what you want it to and you will need to retrieve the correct location from somewhere else.
Specific implementations include using a hidden input field on your form, session state, pulling a descriminator value from your route data, or even just a more constant value like HttpContext.Request.ApplicationPath.
Good luck.
Keep in mind that due to the state-less nature of the web, your ActionResult isn't "called from" your ActionLink as much it is simply a url that the user-agent requested.
Because of this, the only real "built-in" way you can know where that user was coming from is by inspecting the http Request headers to see what the referring page was:
string referrer = Request.Headers["referer"];
You'd then be responsible for parsing out the Action method from this url, if you were going to call it directly. Be aware that this referrer may not be a link within your own site.