How to retrieve query parameter in Wicket - java

I am using wicket application to initiate my Java method in my code. I have the url as follows
http://localhost:8080/web/resources/org.apache.wicket.Application/StartMethod
I want to add an extra option at the end client=cutomser1
http://localhost:8080/web/resources/org.apache.wicket.Application/StartMethod?client=customer1
As I want these use the same code but for different customers
So when I run this URL from command promte it should fetch the Customer1 into my Java code
in this way..
String client = customer1
How can I implement this in Java. I mean I want to fetch this String name customer1

Wicket is strong in data binding and you should take advantage of that.
If you display in the browser data from Customer1, the Wicket knows that when you do requests from that page.
The translation of request parameters to variables happens behind the scene.
That is disconcerting at first but really powerful when used as intended.
I would suggest you select a good tutorial from the answer to this question and go through a couple of examples to see how things are done. This may take an afternoon but this will pay back for itself before the week is out.

I think I am a bit too late, but still I will say that you can use PageParameters in your page and you should make the page bookmarkable.

Related

Want to create a form filler - is java, jsp, html enough?

Summary - Want to make a simple website form filler. The website is NOT mine and I cannot edit its source code. Don't know what tools/languages are needed. Would java, jsp, html be enough ?
Request - Please reconsider your decision to close or downvote. I only need to know if java is enough or not.
There is a form on a website, say for reserving a visit to only one dentist. You fill your details and the date and time you want to visit. Then, it tells you if an appointment can be made or not, somewhere in the webpage.
This web page is NOT protected by CAPTCHA. I don't want to enter my details all the time to look for a reservation. I want to make code to do it for me.
I want to make code which will -
1 - Fill the details into the form and "press" submit.
2 - Then, read the resulting page and find out if a reservation is
available or not. If yes, do something like maybe - pop up a GUI
message, send e-mail or whatever.
3 - Repeat the above steps every 5 hours or so.
What are the languages and tools I would need to do this job ? Would I need more than java, jsp and html (thats all i know now) to make such code ?
Thanks.
I will suggest you try CURL. That will make you solution more simple in my opinion.
You can execute HTTP GET/POST with CURL, which is enough to solve your problem. Give it a try, and if you get block you can ask a more specific question about CURL or HTTP.
Hope it helps.
IMO, If you really just want to fill up some forms to check a reservation, no need to code anything, why not just install a plugin, Selenium, record your actions there and just run it at specified times: http://docs.seleniumhq.org/
Sure.
You need a web server and a database on the back end.
Since you feel comfortable with Java, JSP/HTML would probably be an ideal solution.
IMHO...

java - parsing an aspx website - post parameters

I have my client's e-shop, which is created by another company. I want to parse all the products and put them in an xml. I know how to get to the first page of each "brand" but I have difficulties passing the argument to change the page for the paginated results.
This is the e-shop "http://www.gialia.net.gr/ProductCatalog/20/CAR.aspx" that points to one brand.
When I user tamper-data on firefox I see that when you want to press the second-page of the results is posts the :
"__EVENTTARGET=ctl00%24wpmMain%24wp131820866%24wp512420601%24dpgTop%24ctl01%24ctl01"
the last string: "ct101" means go to page 2, If I change it to ct102 it goes to page 3 etc.
BUT i'm trying to create it as a GET request so I can create these parameters dynamically in my Java code and parse each responce. But when I create the url as:
http://www.gialia.net.gr/ProductCatalog/20/CAR.aspx?__EVENTTARGET=ctl00$wpmMain$wp131820866$wp512420601$dpgTop$ctl01$ctl02
I get no results.
Can someone please take a look and give me some suggestions?
The site you give us here is very poor in design concerning the search engines (SEO), and so the parse of the page one by one is too difficult.
To change page is make post back, and with javascript only. So you must do the same to move to the next page of the catalog, you need to make a full post back of the page with all the parameters.
Now, the page is so bad designed that the programmer have disable the __EVENTVALIDATION of the controls probably because he not let him do wrong things, so when you can tamper the data, but still you need to make post back. By simple type on the url one only parametre the code behind did not understand that is post back. You need to send and at least the Viewstate and the rest hidden parameters.
But isn't more easy to just get from your client access direct to the database and reads them from there ?

How to pass Hidden field values using GET method

I have GET Method. I want to pass something like Student_id in request but without showing it in URL. I know for that we use POST Method. But I dont want to use POST since I am getting someother issues.
If Student_id is something you don't want the user to have, then don't send it. Ever. There's no way to make it safe once it's in a user's hands.
Perhaps you can use a frame as a mask so the domain doesn't change whilst the form submits. You can sneak a REFRESH header in there for 0 seconds with the _top addition, making it nearly impossible for someone to follow your form's weaknesses.
You can't eat the cake and leave it whole.
Your best option is to encrypt the Student_id somehow, you can have your own simple method if it's not very sensitive data, and you can use more complicated algorithms but it can never be 100% safe.
Another option is to not submit the form at all, but AJAX instead to pass the values to server.
You can not do it.
First learn the difference between get and post method.
Get is used to query something with some parameter and post is used to create or update content in the server via http.
It is better using ajax get if you want to hide the parameters form the user.
Look at these link:
http://api.jquery.com/jQuery.get/
http://api.jquery.com/jQuery.ajax/
Cant help to wonder, what does this have anything to do with java.. However, to understand your problem. I would suggest that you use $_SESSSION or setcookie(); So before sending the user to another page, you would first save the user_id in some form.

Passing Variable from one website page to another website page without using QueryString

This question is related to a previous question
Passing Variable from page to page using ASP.NET (C#) without using QueryString
The difference in my case is that the request is coming from a different website (in java) to my website (in asp.net). I do not want the variable to appear in url.
Any suggestions !!
To explain my scenario, we are making a webpage(plugin), which can be called from any other website. To authenticate request, i am looking for a mechanism when other website will pass id & auth-key to my page. This i can use to authenticate the request. I do not want these variable to be visible.
A POST operation would work. The variable would still be part of the request, but it would not be readily visible to the user. I say "readily" visible because it won't be part of the requested URL, but it would be visible if they were to use a tool like Firebug. Short of sharing a database or some other form of "out-of-band" communication, I'm not sure it can be done any other way...
Well as chris mentioned doing a POST is the best way to achieve this. Else you can look at using javascript to achieve the same. Its pretty easy to use JS libraries to achieve the same.
Some of them that come to my mind are
a) Jquery
b) YUI
c) EXT (now Sencha i guess)
But I would definitely recommend jquery.
With jquery you have apis to do post operations. here is more on how to achieve the same.
http://api.jquery.com/jQuery.post/
Hope that helps.
I don't think it can be done without a query string. I know sessions won't work because sessions cannot be shared between Java, Asp, Asp.net, Php etc..., at least not nativly. If you have a database where you store the sessions, you can always use a session id in a query string and therefore simulate cross-language-sessions.

Java Web Application

I am interested in creating a simple web application that will take in user input, convert it to an XML file and send the file to a database.
Coding wise I feel I am okay, it is just the general setup and what implementation to use I am a bit unsure of.
At the moment I have a JSP page containing a form, the user fills out the form and on submit a POST method is sent to a servlet, in the servlet doPost() method the servlet is instantiating a java object and passing it the user inputted data. The java object then writes that data to an XML file and sends it to the database via REST.
All I would be interested to know is if this the standard/optimal way of creating such a web application.
Any and all feedback is appreciated.
Thanks
For a "simple webapplication" this high level approach looks fine in general. However, if you want more critical feedback, you'd need to give more details about the low-level approach. It may for example happen that it isn't memory efficient and thus may break when the webapp is been used by over 10 users concurrently, just to give an example.
I only question the choice for the GET method. You'd normally only use it to retrieve data (SELECT), not to create/alter data (INSERT/UPDATE/DELETE). For that you'd normally use POST, so that no one can execute it "accidently" by just clicking a (bookmarked) link. Changing GET to POST isn't that hard, add method="post" to the <form> element and rename doGet() to doPost().

Categories

Resources