Random URL, Single content - spring-mvc

I'm currently developing an app that generates a URL for a certain number of Subscribers. That has the same content. For example a web page with an image in it.
The URL pattern can be like this http://host:XXXX/foo/randomNumbers
I'm planning to have 7 random numbers. That won't repeat for each subscribers.
I'm currently using Java with SpringMVC for this one. Hope you can help me I'm currently stuck with generating the URLs with the same content.
Thanks! :)

Generate URL any way you like but you have some static aspects:
e.g.
String staticPart = "http://www.yoursite.com/foo/"
//randomly generate the integer number and store in variable (e.g. ranNum)
String finalURL = staticPart + Integer.toString(ranNum)
That way your user gets randomly generated url.
Below is method for accessing a randomly generated URL:
#RequestMapping("/foo/{id}")
public ModelAndView returnView(#PathVariable int id)
I would on top of this store the randomly generated URL for the user and then in the returnView method check if its legitimate.
Content doesn't change that way only url and is made unique to a user.
Is this going to meet your requirement?

Related

Bigcommerce how to get query string from url to store into global variable

My task is the following, I need a way to store a query string value of s and pass it to the merchants Order Confirmation email.
consider the following,...mybigcommerce.com?s=fb.
Let's say that my client posts his website link to facebook and adds in a query string of s with a value of FB (facebook).
The desired result would be that on the initial load of the page, the query string would be saved as a cookie(or in Bigcommerce's case a global or store front variable)
Once I have it saved, I now know that you just simply append the variable to the email template.
example output:
email template source : %name_of_variable%.
My problem is, however, I don't see how to store the value into a variable.
Can I accomplish this without using the API, or for that matter can I do this using the API?
Thank you in advanced, I hope I have provided enough information.
Unfortunately, you cannot create your own variable in the email templates. The variables used here have been created and are supported by code within the core application. As such, it would require a core application change to extend existing functionality/add a variable. There isn't a way for you to write to an existing variable either.

Storing Data on URL change

I am getting a URL from PIC 32 controller using it's post function.
which is like, www.example.com/Default.aspx?x=12&y=23
What I want to do is that when I get the URL, I want to store the values of x and y into SQL Server.
As PIC Controller cannot generate the button event so I need to store the data when the URL is being post on the server.
As per I think this needs to be done on page load. Is it?
Yes do it in a page load.
Access those strings using below syntax:
int x=Integer.ParseInt(Request.QueryString("x").ToString)
int y=Integer.ParseInt(Request.QueryString("y").ToString)
Then insert the values into database.

Send query string parameter from a non-web application

Ok, I've been bugging with this for too long.
I need to call my website from a rough VB.net app. Then only thing I need is to attach a query string parameter to the calling url, so I can distinguish the pages to be shown to different VB app users.
So I want to click a button and launch that website, giving this parameter.
First I was bugging with adding the system.web libraries. Now I can't use Request/Response.QueryString as well.
I tried getting some example help from this post. but as I said before - I cannot make use of Request.QueryString as I cannot import it.
I am stuck here:
Process.Start("http://localhost:56093/WebSite1?id=")
I need to attach a query string parameter to the url and then open the website with that url.
Can someone just give me a sample code for my problem.
Query parameters are parsed by the web server/http handler off the URL you use to call the page. They consist of key and value pairs that come at the end of the URL. Your code is nearly there. Say you needed to pass through the parameters:
ID = 1234
Page = 2
Display = Portrait
Then you'd turn them into a URL like this:
http://localhost:56093/WebSite1?ID=1234&Page=2&Display=Portrait
Therefore in your code you'd have:
Process.Start("http://localhost:56093/WebSite1?ID=1234&Page=2&Display=Portrait");

asp.net change content according to query string

I want to create an asp.net web forms website that has a products page. I want to create a products.aspx page that has a specific layout and there I want to demonstrate the products. So in the url I will have something like www.mysite.gr/products.aspx?productid=1 In other words I want to display different content according to the id from the query string parameter. Please can you propose me some ways to do this and also if you know provide some links that I can study?
Depending on how your site is laid out and how your project is built, there are various ways to approach this. For example, you can get the value of the QueryString like this:
string prodID = Request.QueryString["productid"];
if (prodID != null)
{
//perform database request passing the productid
selectedProduct = GetProductData(prodID);
}
Then, as a simple example, you can add the relevant details. For example, lets say you've got a product class from your GetProdutData() method. You can then fill out the elements on your page with the relevant data.
titleLabel.Text = selectedProduct.Title;
descriptionLabel.Text = selectedProduct.Decription;
image.ImageUrl = selectedProduct.ImageURL;
This is just one approach and there are various others, such as using the MVC pattern.

MVC3 Stripping Query String from my Parameter

I have an MVC3 Action that takes a parameter (a URL) that may have a query string in it. My action signature looks like this:
GetUrl(string url)
I expect to be able to send it urls, and it works every time unless there is a query string in the url. For example, if I navigate to:
MyController/GetUrl/www.google.com
the url parameter comes accross as "www.google.com" -Perfect. However, if I send
MyController/GetUrl/www.google.com/?id=3
the url parameter comes accross as "www.google.com/" How do I get MVC3 to give me the whole URL in that parameter? -Including the query string?
It's simple enough to just URL.Encode the passed in URL on the page but you're opening your self to some possible security problems.
I would suggest you encrypt the url then encode it then pass that as your value, the protects you from having people just passing in anything into your app.
That's because system considers id=3 as its own query string. When you construct the link in the view, you need to use #Url.Encode to convert raw url string to encoded string to be accepted as parameter of the controller.

Resources